Skip to content

Commit

Permalink
Fix upgrade process
Browse files Browse the repository at this point in the history
Correctly save the config file before and restart
the server after an upgrade
  • Loading branch information
Gagi2k committed Jan 12, 2020
1 parent a331b17 commit 0bbcb4e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 13 deletions.
37 changes: 37 additions & 0 deletions postupgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh

# To use important variables from command line use the following code:
COMMAND=$0 # Zero argument is shell command
PTEMPDIR=$1 # First argument is temp folder during install
PSHNAME=$2 # Second argument is Plugin-Name for scipts etc.
PDIR=$3 # Third argument is Plugin installation folder
PVERSION=$4 # Forth argument is Plugin version
#LBHOMEDIR=$5 # Comes from /etc/environment now. Fifth argument is
# Base folder of LoxBerry

# Combine them with /etc/environment
PCGI=$LBPCGI/$PDIR
PHTML=$LBPHTML/$PDIR
PTEMPL=$LBPTEMPL/$PDIR
PDATA=$LBPDATA/$PDIR
PLOG=$LBPLOG/$PDIR # Note! This is stored on a Ramdisk now!
PCONFIG=$LBPCONFIG/$PDIR
PSBIN=$LBPSBIN/$PDIR
PBIN=$LBPBIN/$PDIR

echo "<INFO> Copy back existing config files /tmp/${PDIR}.SAVE/* $PCONFIG/"
cp -v -r /tmp/${PDIR}.SAVE/* $PCONFIG/

echo "<INFO> Remove temporary folder /tmp/${PDIR}.SAVE"
rm -rf /tmp/${PDIR}.SAVE

enabled=`awk -F'[ ]' '/enable/{print $2}' $PCONFIG/wolf_ism8i.conf`

if [ "$enabled" -eq "1" ]; then
# Enable
echo "<INFO> Restarting server"
$PBIN/wolf_server restart > /dev/null 2>&1
fi

# Exit with Status 0
exit 0
18 changes: 5 additions & 13 deletions preupgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,10 @@ PCONFIG=$LBPCONFIG/$PDIR
PSBIN=$LBPSBIN/$PDIR
PBIN=$LBPBIN/$PDIR

echo -n "<INFO> Current working folder is: "
pwd
echo "<INFO> Command is: $COMMAND"
echo "<INFO> Temporary folder is: $PTEMPDIR"
echo "<INFO> (Short) Name is: $PSHNAME"
echo "<INFO> Installation folder is: $PDIR"
echo "<INFO> Plugin version is: $PVERSION"
echo "<INFO> Plugin CGI folder is: $PCGI"
echo "<INFO> Plugin HTML folder is: $PHTML"
echo "<INFO> Plugin Template folder is: $PTEMPL"
echo "<INFO> Plugin Data folder is: $PDATA"
echo "<INFO> Plugin Log folder (on RAMDISK!) is: $PLOG"
echo "<INFO> Plugin CONFIG folder is: $PCONFIG"
echo "<INFO> Creating temporary folders for upgrading /tmp/${PDIR}.SAVE "
mkdir /tmp/${PDIR}.SAVE

echo "<INFO> Backing up existing config files $PCONFIG/* /tmp/${PDIR}.SAVE/ "
cp -v -r $PCONFIG/* /tmp/${PDIR}.SAVE/

exit 0

0 comments on commit 0bbcb4e

Please sign in to comment.