-
Notifications
You must be signed in to change notification settings - Fork 22
/
create_config.sh
executable file
·39 lines (36 loc) · 1.07 KB
/
create_config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
if [ "$SUDO_USER" != "" ]; then
eval CONF_DEST_DIR=~$SUDO_USER
else
CONF_DEST_DIR=~
fi
if [ -f def_config.sh ]; then
ROOTDIR=$(pwd)
else
ROOTDIR=$(pwd)/..
fi
if [ ! -f $CONF_DEST_DIR/.S-config.sh ]; then
echo No user config found in $CONF_DEST_DIR, copying default config
tail -n +5 $ROOTDIR/def_config.sh > $CONF_DEST_DIR/.S-config.sh
if [ "$SUDO_USER" != "" ]; then
chown $SUDO_USER:$SUDO_USER $CONF_DEST_DIR/.S-config.sh
fi
else
sed 's/^#.*//g' $ROOTDIR/def_config.sh > def_file
sed 's/^#.*//g' $CONF_DEST_DIR/.S-config.sh > user_file
if [[ "$(diff -d -B def_file user_file)" != "" && \
$ROOTDIR/def_config.sh -nt $CONF_DEST_DIR/.S-config.sh ]]
then
echo Your config file \($CONF_DEST_DIR/.S-config.sh\) is older
echo than my default config file. If this is ok for you,
echo then just
echo touch $CONF_DEST_DIR/.S-config.sh
echo to eliminate this error.
echo Otherwise
echo rm $CONF_DEST_DIR/.S-config.sh
echo to have your config file updated automatically
echo with default values.
rm def_file user_file
exit
fi
rm def_file user_file
fi