Tidying
This commit is contained in:
parent
e3a7b9ab4e
commit
dbb6eb21ec
|
@ -55,18 +55,18 @@ fi
|
|||
|
||||
|
||||
function update_domains {
|
||||
MICROBLOG_DOMAIN_NAME='microblog'
|
||||
if grep -q "GNU Social domain" $COMPLETION_FILE; then
|
||||
MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "GNU Social domain" | awk -F ':' '{print $2}')
|
||||
fi
|
||||
HUBZILLA_DOMAIN_NAME='hubzilla'
|
||||
if grep -q "Hubzilla domain" $COMPLETION_FILE; then
|
||||
HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
|
||||
fi
|
||||
FULLBLOG_DOMAIN_NAME='blog'
|
||||
if grep -q "Blog domain" $COMPLETION_FILE; then
|
||||
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||
fi
|
||||
MICROBLOG_DOMAIN_NAME='microblog'
|
||||
if grep -q "GNU Social domain" $COMPLETION_FILE; then
|
||||
MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "GNU Social domain" | awk -F ':' '{print $2}')
|
||||
fi
|
||||
HUBZILLA_DOMAIN_NAME='hubzilla'
|
||||
if grep -q "Hubzilla domain" $COMPLETION_FILE; then
|
||||
HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
|
||||
fi
|
||||
FULLBLOG_DOMAIN_NAME='blog'
|
||||
if grep -q "Blog domain" $COMPLETION_FILE; then
|
||||
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||
fi
|
||||
}
|
||||
|
||||
function mount_drive {
|
||||
|
@ -347,6 +347,72 @@ function remove_backup_directory {
|
|||
fi
|
||||
}
|
||||
|
||||
function prepare_directories {
|
||||
# Some miscellaneous preparation for backing up directories
|
||||
if [ -d /home/git/go/src/github.com/gogits ]; then
|
||||
mv /home/git/gogs-repositories/*.git /home/git/gogs-repositories/$ADMIN_USERNAME
|
||||
fi
|
||||
if [ -d /var/lib/tox-bootstrapd ]; then
|
||||
cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd
|
||||
if [ -d /var/lib/tox-bootstrapd/Maildir ]; then
|
||||
rm -rf /var/lib/tox-bootstrapd/Maildir
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_configuration {
|
||||
echo $"Backing up ${PROJECT_NAME} configuration files"
|
||||
if [ ! -d /root/tempbackupconfig ]; then
|
||||
mkdir -p /root/tempbackupconfig
|
||||
fi
|
||||
cp -f $CONFIG_FILE /root/tempbackupconfig
|
||||
cp -f $COMPLETION_FILE /root/tempbackupconfig
|
||||
backup_directory_to_usb /root/tempbackupconfig config
|
||||
}
|
||||
|
||||
function backup_admin_readme {
|
||||
if [ -f /home/$ADMIN_USERNAME/README ]; then
|
||||
echo $"Backing up README"
|
||||
if [ ! -d /home/$ADMIN_USERNAME/tempbackup ]; then
|
||||
mkdir -p /home/$ADMIN_USERNAME/tempbackup
|
||||
fi
|
||||
cp -f /home/$ADMIN_USERNAME/README /home/$ADMIN_USERNAME/tempbackup
|
||||
backup_directory_to_usb /home/$ADMIN_USERNAME/tempbackup readme
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_voip {
|
||||
if [ -f /etc/mumble-server.ini ]; then
|
||||
echo $"Backing up VoIP settings"
|
||||
if [ ! -d /root/tempvoipbackup ]; then
|
||||
mkdir -p /root/tempvoipbackup
|
||||
fi
|
||||
cp -f /etc/mumble-server.ini /root/tempvoipbackup
|
||||
cp -f /var/lib/mumble-server/mumble-server.sqlite /root/tempvoipbackup
|
||||
cp -f /etc/sipwitch.conf /root/tempvoipbackup
|
||||
backup_directory_to_usb /root/tempvoipbackup voip
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_mariadb {
|
||||
if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
|
||||
if [ ! -d /root/tempmariadb ]; then
|
||||
mkdir /root/tempmariadb
|
||||
fi
|
||||
mysqldump --password="$DATABASE_PASSWORD" mysql user > /root/tempmariadb/mysql.sql
|
||||
if [ ! -s /root/tempmariadb/mysql.sql ]; then
|
||||
echo $"Unable to backup mysql settings"
|
||||
rm -rf /root/tempmariadb
|
||||
umount $USB_MOUNT
|
||||
rm -rf $USB_MOUNT
|
||||
exit 8
|
||||
fi
|
||||
echo "$DATABASE_PASSWORD" > /root/tempmariadb/db
|
||||
chmod 400 /root/tempmariadb/db
|
||||
backup_directory_to_usb /root/tempmariadb mariadb
|
||||
fi
|
||||
}
|
||||
|
||||
# has the remove option been set ?
|
||||
remove_option=$2
|
||||
if [[ $1 == "remove" ]]; then
|
||||
|
@ -359,68 +425,12 @@ make_backup_directory
|
|||
check_storage_space_remaining
|
||||
update_domains
|
||||
backup_users
|
||||
|
||||
if [ -d /home/git/go/src/github.com/gogits ]; then
|
||||
mv /home/git/gogs-repositories/*.git /home/git/gogs-repositories/$ADMIN_USERNAME
|
||||
fi
|
||||
if [ -d /var/lib/tox-bootstrapd ]; then
|
||||
cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd
|
||||
if [ -d /var/lib/tox-bootstrapd/Maildir ]; then
|
||||
rm -rf /var/lib/tox-bootstrapd/Maildir
|
||||
fi
|
||||
fi
|
||||
|
||||
prepare_directories
|
||||
backup_directories
|
||||
|
||||
# configuration files
|
||||
echo $"Backing up ${PROJECT_NAME} configuration files"
|
||||
if [ ! -d /root/tempbackupconfig ]; then
|
||||
mkdir -p /root/tempbackupconfig
|
||||
fi
|
||||
cp -f $CONFIG_FILE /root/tempbackupconfig
|
||||
cp -f $COMPLETION_FILE /root/tempbackupconfig
|
||||
backup_directory_to_usb /root/tempbackupconfig config
|
||||
|
||||
# Backup admin user README file
|
||||
if [ -f /home/$ADMIN_USERNAME/README ]; then
|
||||
echo $"Backing up README"
|
||||
if [ ! -d /home/$ADMIN_USERNAME/tempbackup ]; then
|
||||
mkdir -p /home/$ADMIN_USERNAME/tempbackup
|
||||
fi
|
||||
cp -f /home/$ADMIN_USERNAME/README /home/$ADMIN_USERNAME/tempbackup
|
||||
backup_directory_to_usb /home/$ADMIN_USERNAME/tempbackup readme
|
||||
fi
|
||||
|
||||
# Backup VoIP settings
|
||||
if [ -f /etc/mumble-server.ini ]; then
|
||||
echo $"Backing up VoIP settings"
|
||||
if [ ! -d /root/tempvoipbackup ]; then
|
||||
mkdir -p /root/tempvoipbackup
|
||||
fi
|
||||
cp -f /etc/mumble-server.ini /root/tempvoipbackup
|
||||
cp -f /var/lib/mumble-server/mumble-server.sqlite /root/tempvoipbackup
|
||||
cp -f /etc/sipwitch.conf /root/tempvoipbackup
|
||||
backup_directory_to_usb /root/tempvoipbackup voip
|
||||
fi
|
||||
|
||||
# MariaDB settings
|
||||
if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
|
||||
if [ ! -d /root/tempmariadb ]; then
|
||||
mkdir /root/tempmariadb
|
||||
fi
|
||||
mysqldump --password="$DATABASE_PASSWORD" mysql user > /root/tempmariadb/mysql.sql
|
||||
if [ ! -s /root/tempmariadb/mysql.sql ]; then
|
||||
echo $"Unable to backup mysql settings"
|
||||
rm -rf /root/tempmariadb
|
||||
umount $USB_MOUNT
|
||||
rm -rf $USB_MOUNT
|
||||
exit 8
|
||||
fi
|
||||
echo "$DATABASE_PASSWORD" > /root/tempmariadb/db
|
||||
chmod 400 /root/tempmariadb/db
|
||||
backup_directory_to_usb /root/tempmariadb mariadb
|
||||
fi
|
||||
|
||||
backup_configuration
|
||||
backup_admin_readme
|
||||
backup_voip
|
||||
backup_mariadb
|
||||
unmount_drive
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue