Commit 4672f1f650ad5dcc35e1668ba94a29d35fa2d9de

Authored by isisadmin
1 parent 3ce46819

update

Showing 1 changed file with 36 additions and 5 deletions
spod-manager.sh
@@ -72,7 +72,7 @@ fi @@ -72,7 +72,7 @@ fi
72 ############################################################################# 72 #############################################################################
73 SCRIPT_NAME="spod-manager.sh" 73 SCRIPT_NAME="spod-manager.sh"
74 #Arguments 74 #Arguments
75 -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: -- "$@") 75 +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: -- "$@")
76 76
77 if [ $? -ne 0 ]; then 77 if [ $? -ne 0 ]; then
78 echo "error in parameters." 78 echo "error in parameters."
@@ -91,7 +91,7 @@ while true; do @@ -91,7 +91,7 @@ while true; do
91 echo " " 91 echo " "
92 echo "list of arguments:" 92 echo "list of arguments:"
93 echo "-h, --help show commands help" 93 echo "-h, --help show commands help"
94 - echo "-a, --action=ACTION specify an action install, uninstall, update, backup, restore." 94 + echo "-a, --action=ACTION specify an action install, uninstall, update, backup, restoredb, restoreall."
95 echo "-m, --mysql-username=username specify the username of mysql (*)." 95 echo "-m, --mysql-username=username specify the username of mysql (*)."
96 echo "-n, --mysql-password=password specify the password of mysql server (*)." 96 echo "-n, --mysql-password=password specify the password of mysql server (*)."
97 echo "-o, --mysql-address=address specify the address of mysql server (deafult is localhost)." 97 echo "-o, --mysql-address=address specify the address of mysql server (deafult is localhost)."
@@ -101,6 +101,7 @@ while true; do @@ -101,6 +101,7 @@ while true; do
101 echo "-s, --spod-git-address=address:port specify the SPOD git server (deafult is service.routetopa.eu:7480)." 101 echo "-s, --spod-git-address=address:port specify the SPOD git server (deafult is service.routetopa.eu:7480)."
102 echo "-w, --spod-hostname=hostname specify the SPOD host name (example http://spod.routetopa.eu/)." 102 echo "-w, --spod-hostname=hostname specify the SPOD host name (example http://spod.routetopa.eu/)."
103 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)." 103 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)."
  104 + echo "-e, --spod-www-backup=www-folder specify the SPOD www folder path."
104 echo "-b, --backup-dir=DIR specify the directory where store the spod backup (default is current directory)." 105 echo "-b, --backup-dir=DIR specify the directory where store the spod backup (default is current directory)."
105 echo "* the arguments is required." 106 echo "* the arguments is required."
106 exit 0; 107 exit 0;
@@ -138,6 +139,9 @@ while true; do @@ -138,6 +139,9 @@ while true; do
138 -d|--spod-database-version) 139 -d|--spod-database-version)
139 DB="$2"; shift 140 DB="$2"; shift
140 ;; 141 ;;
  142 + -e|--spod-www-backup)
  143 + SPODWWW="$2"; shift
  144 + ;;
141 --) shift; break 145 --) shift; break
142 ;; 146 ;;
143 *) 147 *)
@@ -234,17 +238,44 @@ echo "SPOD MANAGER Action: $ACTION ..." @@ -234,17 +238,44 @@ echo "SPOD MANAGER Action: $ACTION ..."
234 cp -r /var/www $BACKUPDIR/$DATEDIR/var 238 cp -r /var/www $BACKUPDIR/$DATEDIR/var
235 service apache2 start 239 service apache2 start
236 ;; 240 ;;
237 - "restore")  
238 - if [ -z "$MYSQLUSERNAME" ] || [ -z "$MYSQLPASSWORD" ] ; 241 + "restoredb")
  242 + if [ -z "$MYSQLUSERNAME" ] || [ -z "$MYSQLPASSWORD" ] || [ -z "$DB" ];
239 then 243 then
240 - echo "You must specify the mysql password and username to unistall SPOD." 244 + echo "You must specify the mysql password and username, db dump path to restore SPOD."
241 exit -2 245 exit -2
242 fi 246 fi
243 service apache2 stop 247 service apache2 stop
  248 + mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST -e "drop database oxwall;"
244 mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST -e "create database if not exists oxwall;" 249 mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST -e "create database if not exists oxwall;"
245 mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST --database=oxwall < $DB 250 mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST --database=oxwall < $DB
246 service apache2 start 251 service apache2 start
247 ;; 252 ;;
  253 + "restoreall")
  254 + if [ -z "$MYSQLUSERNAME" ] || [ -z "$MYSQLPASSWORD" ] || [ -z "$SPODWWW" ];
  255 + then
  256 + echo "You must specify the mysql password and username, SPOD backup dir and DB dump path to restore SPOD."
  257 + exit -2
  258 + fi
  259 + service apache2 stop
  260 + mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST -e "drop database oxwall;"
  261 + mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST -e "create database if not exists oxwall;"
  262 + mysql -u $MYSQLUSERNAME -p$MYSQLPASSWORD --host=$MYSQLHOST --database=oxwall < $DB
  263 + rm -rf /var/www/*
  264 + rm -rf /var/www/.[^.]*
  265 + cp -r $SPODWWW /var/www
  266 +
  267 + cd /var/www
  268 + git init
  269 + git remote add origin http://$GITUSER:$GITPASSWORD@$GITSPOD/isislab/spod-core.git
  270 + cd /var/www/ow_plugins
  271 + git init
  272 + git remote add origin http://$GITUSER:$GITPASSWORD@$GITSPOD/isislab/spod-plugins.git
  273 + cd /var/www/ow_themes
  274 + git init
  275 + git remote add origin http://$GITUSER:$GITPASSWORD@$GITSPOD/isislab/spod-themes.git
  276 + service apache2 start
  277 +
  278 + ;;
248 "update") 279 "update")
249 if [ -z "$GITUSER" ] || [ -z "$GITEMAIL" ] || [ -z "$GITPASSWORD" ] || [ -z "$HOSTNAMESPOD" ]; 280 if [ -z "$GITUSER" ] || [ -z "$GITEMAIL" ] || [ -z "$GITPASSWORD" ] || [ -z "$HOSTNAMESPOD" ];
250 then 281 then