fix backup only to clean home directory

This commit is contained in:
dmacias72 2016-02-20 12:31:41 -07:00
parent f1fe99d70d
commit be66068f1c

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# start/stop/shutdown/restart shellinabox daemon: # start/stop/startup/shutdown/backup/restore/restart shellinabox daemon:
PROG="shellinaboxd" PROG="shellinaboxd"
SHELLINABOXD="/usr/sbin/$PROG" SHELLINABOXD="/usr/sbin/$PROG"
@ -83,32 +83,54 @@ shellinaboxd_restart() {
shellinaboxd_start shellinaboxd_start
} }
# Restore shellinaboxd: # Restore home directory
shellinaboxd_restore() { shellinaboxd_restore() {
if [ "$BACKUP" == "enable" ]; then if [[ "$BACKUP" == "enable" && ! -e "/root/.bash_history" ]]; then
# backup home directory # restore home directory
echo "restoring home directory..." echo "restoring home directory..."
tar -zxf $PLGPATH/home_directory.tar.gz -p -C / > /dev/null 2>&1
sleep 1 sleep 1
tar -zxf $PLGPATH/home_directory.tar.gz -p -C / > /dev/null 2>&1
else
echo "Backup is not enabled or home directory is not clean"
fi fi
shellinaboxd_start
} }
# Shutdown shellinaboxd: # Backup home directory:
shellinaboxd_shutdown() { shellinaboxd_backup() {
if [ "$BACKUP" == "enable" ]; then if [ "$BACKUP" == "enable" ]; then
# backup home directory # backup home directory
echo "saving home directory..." echo "saving home directory..."
tar -zcf $PLGPATH/home_directory.tar.gz -p -C / root > /dev/null 2>&1
sleep 1 sleep 1
tar -zcf $PLGPATH/home_directory.tar.gz -p -C / root > /dev/null 2>&1
else
echo "Backup is not enabled"
fi fi
}
# Start and restore for system boot:
shellinaboxd_startup() {
shellinaboxd_restore
sleep 1
shellinaboxd_start
}
# Shutdown and backup for system shutdown or reboot:
shellinaboxd_shutdown() {
shellinaboxd_backup
sleep 1
shellinaboxd_stop shellinaboxd_stop
} }
case "$1" in case "$1" in
'backup')
shellinaboxd_backup
;;
'start') 'start')
shellinaboxd_start shellinaboxd_start
;; ;;
'startup')
shellinaboxd_startup
;;
'stop') 'stop')
shellinaboxd_stop shellinaboxd_stop
;; ;;
@ -122,5 +144,5 @@ case "$1" in
shellinaboxd_restart shellinaboxd_restart
;; ;;
*) *)
echo "usage rc.shellinaboxd: start|stop|shutdown|restore|restart" echo "usage rc.shellinaboxd: start|stop|startup|shutdown|backup|restore|restart"
esac esac