Skip to content
Permalink
Browse files

Improve output of nems-update

  • Loading branch information...
NEMS Linux
NEMS Linux committed Feb 14, 2019
1 parent 803afbc commit 6f16a35e882a5569cbdd952671c2dd1a55a17b68
Showing with 74 additions and 24 deletions.
  1. +74 −24 update.sh
@@ -1,20 +1,17 @@
#!/bin/bash

echo ""
echo "NEMS Update"
echo ""

if [[ $EUID -ne 0 ]]; then
echo "ERROR: This script must be run as root" 2>&1
exit 1
else
# Ping Google to see if Internet is up. Don't begin until we have Internet.
count=1
while ! ping -c 1 -W 1 google.com; do
if [ $count -eq 60 ]
then
echo "Google not responding. Resuming, but if Internet is down, updates will fail."
break;
fi
((count++))
sleep 1
done
online=$(/usr/local/bin/nems-info online)
if [[ $online == 0 ]]; then
echo "*** NEMS cannot detect your Internet connection. Please make sure you are online. ***"
fi

# Just in case nems-quickfix is running
update=$(/usr/local/bin/nems-info update)
@@ -39,9 +36,14 @@ else
done
fi

echo "Updating NEMS Core Components"

# Update nems-migrator
printf "Updating nems-migrator... "
echo " - nems-migrator"
cd /root/nems/nems-migrator
commit=`git rev-parse HEAD`
echo " Commit: $commit"
printf " "
result=`git pull`
echo $result
if [[ $result =~ 'error:' ]]; then
@@ -57,13 +59,21 @@ else
mv /root/nems/nems-migrator~ /root/nems/nems-migrator
fi
fi
commitnew=`git rev-parse HEAD`
if [[ $commit == $commitnew ]]; then
echo " No changes."
else
echo " New Commit: $commit"
fi
# Get the latest version data from nems-migrator
cp -f /root/nems/nems-migrator/data/nems/ver-current.txt /var/www/html/inc/ver-available.txt
echo "Done."

# Update nems-www
printf "Updating nems-www... "
echo " - nems-www... "
cd /var/www/html
commit=`git rev-parse HEAD`
echo " Commit: $commit"
printf " "
result=`git pull`
echo $result
if [[ $result =~ 'error:' ]]; then
@@ -81,11 +91,19 @@ else
mv /var/www/nems-www~ /var/www/html
fi
fi
echo "Done."
commitnew=`git rev-parse HEAD`
if [[ $commit == $commitnew ]]; then
echo " No changes."
else
echo " New Commit: $commit"
fi

# Update nems-admin
printf "Updating nems-admin... "
echo " - nems-admin... "
cd /root/nems/nems-admin
commit=`git rev-parse HEAD`
echo " Commit: $commit"
printf " "
result=`git pull`
echo $result
if [[ $result =~ 'error:' ]]; then
@@ -101,11 +119,19 @@ else
mv /root/nems/nems-admin~ /root/nems/nems-admin
fi
fi
echo "Done."
commitnew=`git rev-parse HEAD`
if [[ $commit == $commitnew ]]; then
echo " No changes."
else
echo " New Commit: $commit"
fi

# Update nems-nconf
printf "Updating nconf... "
echo " - nconf... "
cd /var/www/nconf
commit=`git rev-parse HEAD`
echo " Commit: $commit"
printf " "
result=`git pull`
echo $result
if [[ $result =~ 'error:' ]]; then
@@ -121,12 +147,20 @@ else
mv /var/www/nconf~ /var/www/nconf
fi
fi
echo "Done."
commitnew=`git rev-parse HEAD`
if [[ $commit == $commitnew ]]; then
echo " No changes."
else
echo " New Commit: $commit"
fi

# Update nems-tools
printf "Updating nems-tools... "
echo " - nems-tools... "
if [[ -d /root/nems/nems-tools ]]; then
cd /root/nems/nems-tools
commit=`git rev-parse HEAD`
echo " Commit: $commit"
printf " "
result=`git pull`
echo $result
if [[ $result =~ 'error:' ]]; then
@@ -142,18 +176,26 @@ else
mv /root/nems/nems-tools~ /root/nems/nems-tools
fi
fi
echo "Done."
else
echo "nems-tools is not installed."
cd /root/nems
git clone https://github.com/Cat5TV/nems-tools
echo 'Installed nems-tools.'
fi
commitnew=`git rev-parse HEAD`
if [[ $commit == $commitnew ]]; then
echo " No changes."
else
echo " New Commit: $commit"
fi

# Update self
printf "Updating nems-scripts... "
echo " - nems-scripts... "
if [ -d /usr/local/share/nems/nems-scripts ]; then
cd /usr/local/share/nems/nems-scripts
commit=`git rev-parse HEAD`
echo " Commit: $commit"
printf " "
result=`git pull`
echo $result
if [[ $result =~ 'error:' ]]; then
@@ -170,12 +212,19 @@ else
fi
fi
fi
commitnew=`git rev-parse HEAD`
if [[ $commit == $commitnew ]]; then
echo " No changes."
else
echo " New Commit: $commit"
fi

# Check if we are still on legacy 1.1 or 1.2.x and update that way, otherwise fixes will not run to patch it
if [ -d /home/pi/nems-scripts ]; then
echo "*** You need to upgrade your NEMS server to a current version! ***"
cd /home/pi/nems-scripts && git pull
fi
echo "Done."
echo ""

# Perform any fixes that have been released since NEMS was built
printf "Running updates and fixes... "
@@ -186,9 +235,10 @@ else
if [ -d /home/pi/nems-scripts ]; then
/home/pi/nems-scripts/fixes.sh
fi
echo "Done."
echo ""

fi
echo "Done."
echo ""

rm -f /var/run/nems-update.pid

0 comments on commit 6f16a35

Please sign in to comment.
You can’t perform that action at this time.