Skip to content

Commit 2762a9c

Browse files
author
Kristan Kenney
committed
Sort configuration keys in hestia.conf on change
Prevent configuration file from becoming a mess Sort configuration file at end of installation and make backup
1 parent 8ce2996 commit 2762a9c

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

bin/v-change-sys-config-value

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ else
4848
sed -i "s|$key=.*|$key='$value'|g" $HESTIA/conf/hestia.conf
4949
fi
5050

51+
# Sort configuration file in alphabetical order on change
52+
sort $HESTIA/conf/hestia.conf -o /tmp/updconf
53+
mv $HESTIA/conf/hestia.conf $HESTIA/conf/hestia.conf.bak
54+
mv /tmp/updconf $HESTIA/conf/hestia.conf
55+
rm -f $HESTIA/conf/hestia.conf.bak
56+
5157
#----------------------------------------------------------#
5258
# Hestia #
5359
#----------------------------------------------------------#

install/hst-install-debian.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,20 @@ write_config_value() {
156156
echo "$key='$value'" >> $HESTIA/conf/hestia.conf
157157
}
158158

159+
# Sort configuration file values
160+
# Write final copy to $HESTIA/conf/hestia.conf for active usage
161+
# Duplicate file to $HESTIA/conf/defaults/hestia.conf to restore known good installation values
162+
sort_config_file(){
163+
sort $HESTIA/conf/hestia.conf -o /tmp/updconf
164+
mv $HESTIA/conf/hestia.conf $HESTIA/conf/hestia.conf.bak
165+
mv /tmp/updconf $HESTIA/conf/hestia.conf
166+
rm -f $HESTIA/conf/hestia.conf.bak
167+
if [ ! -d "$HESTIA/conf/defaults/" ]; then
168+
mkdir -p "$HESTIA/conf/defaults/"
169+
fi
170+
cp $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
171+
}
172+
159173
#----------------------------------------------------------#
160174
# Verifications #
161175
#----------------------------------------------------------#
@@ -1875,4 +1889,8 @@ if [ "$interactive" = 'yes' ]; then
18751889
fi
18761890
fi
18771891

1892+
# Clean-up
1893+
# Sort final configuration file
1894+
sort_config_file
1895+
18781896
# EOF

install/hst-install-ubuntu.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,20 @@ write_config_value() {
137137
echo "$key='$value'" >> $HESTIA/conf/hestia.conf
138138
}
139139

140+
# Sort configuration file values
141+
# Write final copy to $HESTIA/conf/hestia.conf for active usage
142+
# Duplicate file to $HESTIA/conf/defaults/hestia.conf to restore known good installation values
143+
sort_config_file(){
144+
sort $HESTIA/conf/hestia.conf -o /tmp/updconf
145+
mv $HESTIA/conf/hestia.conf $HESTIA/conf/hestia.conf.bak
146+
mv /tmp/updconf $HESTIA/conf/hestia.conf
147+
rm -f $HESTIA/conf/hestia.conf.bak
148+
if [ ! -d "$HESTIA/conf/defaults/" ]; then
149+
mkdir -p "$HESTIA/conf/defaults/"
150+
fi
151+
cp $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
152+
}
153+
140154
#----------------------------------------------------------#
141155
# Verifications #
142156
#----------------------------------------------------------#
@@ -1909,4 +1923,8 @@ if [ "$interactive" = 'yes' ]; then
19091923
fi
19101924
fi
19111925

1926+
# Clean-up
1927+
# Sort final configuration file
1928+
sort_config_file
1929+
19121930
# EOF

0 commit comments

Comments
 (0)