diff --git a/spod-manager.sh b/spod-manager.sh index b613dce..8afb5b1 100755 --- a/spod-manager.sh +++ b/spod-manager.sh @@ -72,7 +72,7 @@ fi ############################################################################# SCRIPT_NAME="spod-manager.sh" #Arguments -OPTIONS=$(getopt -o ha:b:m:n:o:p:q:r:s:w:d: -l help,action:,backup-dir:,mysql-username:,mysql-password:,mysql-address:,spod-git-username:,spod-git-email:,spod-git-password:,spod-git-address:,spod-hostname:,spod-database-version: -- "$@") +OPTIONS=$(getopt -o ha:b:m:n:o:p:q:r:s:w:d:e: -l help,action:,backup-dir:,mysql-username:,mysql-password:,mysql-address:,spod-git-username:,spod-git-email:,spod-git-password:,spod-git-address:,spod-hostname:,spod-database-version:spod-www-backup: -- "$@") if [ $? -ne 0 ]; then echo "error in parameters." @@ -91,7 +91,7 @@ while true; do echo " " echo "list of arguments:" echo "-h, --help show commands help" - echo "-a, --action=ACTION specify an action install, uninstall, update, backup, restore." + echo "-a, --action=ACTION specify an action install, uninstall, update, backup, restoredb, restoreall." echo "-m, --mysql-username=username specify the username of mysql (*)." echo "-n, --mysql-password=password specify the password of mysql server (*)." echo "-o, --mysql-address=address specify the address of mysql server (deafult is localhost)." @@ -101,6 +101,7 @@ while true; do echo "-s, --spod-git-address=address:port specify the SPOD git server (deafult is service.routetopa.eu:7480)." echo "-w, --spod-hostname=hostname specify the SPOD host name (example http://spod.routetopa.eu/)." echo "-d, --spod-database-version=db specify the SPOD db git path located in db_dump of SPOD git core (example in backup action: oxwall_v.0.1_antares.sql, deafults is really simple SPOD and Oxwall installationi; in restore action use a local db dump)." + echo "-e, --spod-www-backup=www-folder specify the SPOD www folder path." echo "-b, --backup-dir=DIR specify the directory where store the spod backup (default is current directory)." echo "* the arguments is required." exit 0; @@ -138,6 +139,9 @@ while true; do -d|--spod-database-version) DB="$2"; shift ;; + -e|--spod-www-backup) + SPODWWW="$2"; shift + ;; --) shift; break ;; *) @@ -234,17 +238,44 @@ echo "SPOD MANAGER Action: $ACTION ..." cp -r /var/www $BACKUPDIR/$DATEDIR/var service apache2 start ;; - "restore") - if [ -z "$MYSQLUSERNAME" ] || [ -z "$MYSQLPASSWORD" ] ; + "restoredb") + if [ -z "$MYSQLUSERNAME" ] || [ -z "$MYSQLPASSWORD" ] || [ -z "$DB" ]; then - echo "You must specify the mysql password and username to unistall SPOD." + echo "You must specify the mysql password and username, db dump path to restore SPOD." exit -2 fi service apache2 stop + mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST -e "drop database oxwall;" mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST -e "create database if not exists oxwall;" mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST --database=oxwall < $DB service apache2 start ;; + "restoreall") + if [ -z "$MYSQLUSERNAME" ] || [ -z "$MYSQLPASSWORD" ] || [ -z "$SPODWWW" ]; + then + echo "You must specify the mysql password and username, SPOD backup dir and DB dump path to restore SPOD." + exit -2 + fi + service apache2 stop + mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST -e "drop database oxwall;" + mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST -e "create database if not exists oxwall;" + mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST --database=oxwall < $DB + rm -rf /var/www/* + rm -rf /var/www/.[^.]* + cp -r $SPODWWW /var/www + + cd /var/www + git init + git remote add origin http://$GITUSER:$GITPASSWORD@$GITSPOD/isislab/spod-core.git + cd /var/www/ow_plugins + git init + git remote add origin http://$GITUSER:$GITPASSWORD@$GITSPOD/isislab/spod-plugins.git + cd /var/www/ow_themes + git init + git remote add origin http://$GITUSER:$GITPASSWORD@$GITSPOD/isislab/spod-themes.git + service apache2 start + + ;; "update") if [ -z "$GITUSER" ] || [ -z "$GITEMAIL" ] || [ -z "$GITPASSWORD" ] || [ -z "$HOSTNAMESPOD" ]; then