Last active
December 21, 2015 14:39
-
-
Save kwikwag/6320783 to your computer and use it in GitHub Desktop.
suggestion for maintaining config of a system: maintain a list all manually-edited files (/opt/admin/config/FILES), use this script with suggested cron jobs to keep a hierarchy of config files in this central place which is also easy to back up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# suggested daily cron jobs: | |
# 7 2 * * * /opt/admin/scripts/link-config-files.sh | |
# 8 3 * * * /opt/admin/scripts/backup-dir.sh /opt/admin | |
# | |
# example FILES format: | |
# /etc/httpd/conf/httpd.conf | |
# /etc/fail2ban/jails.conf | |
BASE_CONFIG=/opt/admin/config | |
FILE_LIST=${BASE_CONFIG}/FILES | |
for DIR in etc; do | |
rm -r $BASE_CONFIG/$DIR | |
done | |
cat ${FILE_LIST} | sed 's/#.*$//' | sed '/^\s*$/d' | while read FILE; do | |
mkdir -p ${BASE_CONFIG}`dirname ${FILE}` | |
ln -s ${FILE} ${BASE_CONFIG}${FILE} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for backup-dir.sh, see https://gist.github.com/kwikwag/6320820