Tidying restore from usb

This commit is contained in:
Bob Mottram 2015-09-20 15:43:27 +01:00
parent b41b4652c2
commit cd12bb0879
1 changed files with 54 additions and 127 deletions

View File

@ -2866,6 +2866,52 @@ function restore_directory_from_usb {
fi
}
function restore_database {
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo "if [ -d $USB_MOUNT/backup/${1} ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " echo \"Restoring ${1} database\"" >> /usr/bin/$RESTORE_SCRIPT_NAME
restore_directory_from_usb /root/temp${1}data ${1}data
echo " if [ ! -f /root/temp${1}data/usb/backup/${1}data/temp${1}data/${1}.sql ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " echo \"Unable to restore ${1} database\"" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/temp${1}data' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 503' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD ' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo "${1} -o < /root/temp${1}data/usb/backup/${1}data/temp${1}data/${1}.sql)" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 964' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " shred -zu /root/temp${1}data/usb/backup/${1}data/temp${1}data/*" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf /root/temp${1}data" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " echo \"Restoring ${1} installation\"" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " if [ ! -d /root/temp${1} ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " mkdir /root/temp${1}" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
restore_directory_from_usb /root/temp${1} ${1}
echo " if [ ${2} ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " if [ -d /var/www/${2}/htdocs ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf /var/www/${2}/htdocs" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " mv /root/temp${1}/usb/backup/${1}/www/${2}/htdocs /var/www/${2}/" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 683' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' # Ensure that the bundled SSL cert is being used' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " if [ -f /etc/ssl/certs/${2}.bundle.crt ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " sed -i 's|${2}.crt|${2}.bundle.crt|g' /etc/nginx/sites-available/${2}" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/temp${1}' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
}
function create_restore_script {
if grep -Fxq "create_restore_script" $COMPLETION_FILE; then
return
@ -3184,85 +3230,16 @@ function create_restore_script {
if grep -Fxq "install_gnu_social" $COMPLETION_FILE; then
BACKUP_INCLUDES_WEBSITES="yes"
echo "if [ -d $USB_MOUNT/backup/gnusocial ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring microblog database"' >> /usr/bin/$RESTORE_SCRIPT_NAME
restore_directory_from_usb /root/tempgnusocialdata gnusocialdata
echo ' if [ ! -f /root/tempgnusocialdata/usb/backup/gnusocialdata/tempgnusocialdata/gnusocial.sql ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Unable to restore microblog database"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempgnusocialdata' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 503' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD gnusocial -o < /root/tempgnusocialdata/usb/backup/gnusocialdata/tempgnusocialdata/gnusocial.sql)' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 964' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' shred -zu /root/tempgnusocialdata/usb/backup/gnusocialdata/tempgnusocialdata/*' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempgnusocialdata' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring microblog installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! -d /root/tempgnusocial ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mkdir /root/tempgnusocial' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
restore_directory_from_usb /root/tempgnusocial gnusocial
echo " rm -rf /var/www/$MICROBLOG_DOMAIN_NAME/htdocs" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " mv /root/tempgnusocial/usb/backup/gnusocial/www/$MICROBLOG_DOMAIN_NAME/htdocs /var/www/$MICROBLOG_DOMAIN_NAME/" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 683' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempgnusocial' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' # Ensure that the bundled SSL cert is being used' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " if [ -f /etc/ssl/certs/$MICROBLOG_DOMAIN_NAME.bundle.crt ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " sed -i 's|$MICROBLOG_DOMAIN_NAME.crt|$MICROBLOG_DOMAIN_NAME.bundle.crt|g' /etc/nginx/sites-available/$MICROBLOG_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
restore_database gnusocial $MICROBLOG_DOMAIN_NAME
fi
if grep -Fxq "install_hubzilla" $COMPLETION_FILE; then
BACKUP_INCLUDES_WEBSITES="yes"
restore_database hubzilla $HUBZILLA_DOMAIN_NAME
echo "if [ -d $USB_MOUNT/backup/hubzilla ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring Hubzilla database"' >> /usr/bin/$RESTORE_SCRIPT_NAME
restore_directory_from_usb /root/temphubzilladata hubzilladata
echo ' if [ ! -f /root/temphubzilladata/usb/backup/hubzilladata/temphubzilladata/hubzilla.sql ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Unable to restore Hubzilla database"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/temphubzilladata' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 504' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD hubzilla -o < /root/temphubzilladata/usb/backup/hubzilladata/temphubzilladata/hubzilla.sql)' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 965' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' shred -zu /root/temphubzilladata/usb/backup/hubzilladata/temphubzilladata/*' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/temphubzilladata' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring Hubzilla installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME
restore_directory_from_usb /root/temphubzilla hubzilla
echo " rm -rf /var/www/$HUBZILLA_DOMAIN_NAME/htdocs" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " cp -r /root/temphubzilla/usb/backup/hubzilla/www/$HUBZILLA_DOMAIN_NAME/htdocs/* /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' else' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " mv /root/temphubzilla/usb/backup/hubzilla/www/$HUBZILLA_DOMAIN_NAME/htdocs /var/www/$HUBZILLA_DOMAIN_NAME/" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 759' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/temphubzilla' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' # Ensure that the bundled SSL cert is being used' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " if [ -f /etc/ssl/certs/$HUBZILLA_DOMAIN_NAME.bundle.crt ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " sed -i 's|$HUBZILLA_DOMAIN_NAME.crt|$HUBZILLA_DOMAIN_NAME.bundle.crt|g' /etc/nginx/sites-available/$HUBZILLA_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " if [ ! -d /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]/smarty3 ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " mkdir -p /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]/smarty3" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " fi" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " chmod 777 /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]/smarty3" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " chown -R www-data:www-data /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/*" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3271,31 +3248,8 @@ function create_restore_script {
if grep -Fxq "install_owncloud" $COMPLETION_FILE; then
BACKUP_INCLUDES_WEBSITES="yes"
echo "if [ -d $USB_MOUNT/backup/owncloud ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring owncloud database"' >> /usr/bin/$RESTORE_SCRIPT_NAME
restore_directory_from_usb /root/tempownclouddata ownclouddata
echo ' if [ ! -f /root/tempownclouddata/usb/backup/ownclouddata/tempownclouddata/owncloud.sql ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Unable to restore Owncloud database"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempownclouddata' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 505' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD owncloud -o < /root/tempownclouddata/usb/backup/ownclouddata/tempownclouddata/owncloud.sql)' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 965' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring Owncloud installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME
restore_directory_from_usb /root/tempowncloud owncloud
echo " cp -r /root/tempowncloud/usb/backup/owncloud/lib/owncloud/* /var/lib/owncloud/" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 981' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
restore_database owncloud $OWNCLOUD_DOMAIN_NAME
echo "if [ -d $USB_MOUNT/backup/owncloud2 ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
restore_directory_from_usb /root/tempowncloud2 owncloud2
echo " cp -r /root/tempowncloud2/usb/backup/owncloud2/owncloud/* /etc/owncloud/" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3303,40 +3257,19 @@ function create_restore_script {
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 982' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempowncloud' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempowncloud2' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempownclouddata' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' chown -R www-data:www-data /var/lib/owncloud/data' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' chown -R www-data:www-data /var/lib/owncloud/backup' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' chown -R www-data:www-data /var/lib/owncloud/assets' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' occ files:scan $MY_USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' # Ensure that the bundled SSL cert is being used' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " if [ -f /etc/ssl/certs/$OWNCLOUD_DOMAIN_NAME.bundle.crt ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " sed -i 's|$OWNCLOUD_DOMAIN_NAME.crt|$OWNCLOUD_DOMAIN_NAME.bundle.crt|g' /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
fi
if grep -Fxq "install_gogs" $COMPLETION_FILE; then
BACKUP_INCLUDES_WEBSITES="yes"
restore_database gogs $GIT_DOMAIN_NAME
echo "if [ -d $USB_MOUNT/backup/gogs ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring gogs database"' >> /usr/bin/$RESTORE_SCRIPT_NAME
restore_directory_from_usb /root/tempgogsdata gogsdata
echo ' if [ ! -f /root/tempgogsdata/usb/backup/gogsdata/tempgogsdata/gogs.sql ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Unable to restore Gogs database"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempgogsdata' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 505' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD gogs -o < /root/tempgogsdata/usb/backup/gogsdata/tempgogsdata/gogs.sql)' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "$mysqlsuccess"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 965' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring Gogs settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
restore_directory_from_usb /root/tempgogs gogs
echo ' if [ ! -d /home/git/go/src/github.com/gogits/gogs/custom ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3367,15 +3300,9 @@ function create_restore_script {
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 8463' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempgogs' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempgogsdata' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempgogsrepos' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempgogsssh' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' chown -R git:git /home/git' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' # Ensure that the bundled SSL cert is being used' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " if [ -f /etc/ssl/certs/$GIT_DOMAIN_NAME.bundle.crt ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " sed -i 's|$GIT_DOMAIN_NAME.crt|$GIT_DOMAIN_NAME.bundle.crt|g' /etc/nginx/sites-available/$GIT_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
fi