PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/upgrade-conffile.sh

http://github.com/sukria/Backup-Manager
Shell | 42 lines | 28 code | 5 blank | 9 comment | 4 complexity | ed0eca007497953f4bc25fbe7a802ec7 MD5 | raw file
 1#! /usr/bin/env bash
 2
 3# This will assist you for upgrading a conffile of version prior
 4# to 0.5.9.
 5#
 6# Usage:
 7#    upgrade-conffile.sh <CONFFILE>
 8#
 9# It will replace every deprecated confiugration key with the new name
10# and will show you the diff before applying it.
11
12set -e
13
14for file in "$1"
15do
16	sed \
17	-e 's/BM_ARCHIVES_REPOSITORY/BM_REPOSITORY_ROOT/g' \
18	-e 's/BM_USER/BM_REPOSITORY_USER/g' \
19	-e 's/BM_GROUP/BM_REPOSITORY_GROUP/g' \
20	-e 's/BM_MAX_TIME_TO_LIVE/BM_ARCHIVE_TTL/g' \
21	-e 's/BM_PURGE_DUPLICATES/BM_ARCHIVE_PURGEDUPS/g' \
22	-e 's/BM_ARCHIVES_PREFIX/BM_ARCHIVE_PREFIX/g' \
23	-e 's/BM_FILETYPE/BM_TARBALL_FILETYPE/g' \
24	-e 's/BM_BACKUP_METHOD/BM_ARCHIVE_METHOD/g' \
25	-e 's/BM_NAME_FORMAT/BM_TARBALL_NAMEFORMAT/g' \
26	-e 's/BM_DUMP_SYMLINKS/BM_TARBALL_DUMPSYMLINKS/g' \
27	-e 's/BM_DIRECTORIES_BLACKLIST/BM_TARBALL_BLACKLIST/g' \
28	-e 's/BM_DIRECTORIES/BM_TARBALL_DIRECTORIES/g' \
29	-e 's/BM_FTP_PURGE/BM_UPLOAD_FTPPURGE/g' < $file > $file.tmp
30	
31	diff -ubB $file $file.tmp | less
32	
33	echo -n "Apply changes to $file? [y/N] "
34	read ret
35	if [[ -z $ret ]]; then
36		ret="n"
37	fi
38	if [[ $ret = y ]] || [[ $ret = Y ]]; then
39		mv $file.tmp $file
40	fi
41	rm -f $file.tmp
42done