nodejs: add uninstall to script

This commit is contained in:
openoms 2020-05-29 15:21:00 +01:00
parent e8a837af27
commit c38051e6b5
No known key found for this signature in database
GPG key ID: 5BFB77609B081B65

View file

@ -3,7 +3,7 @@
# command info
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "small config script to install NodeJs"
echo "bonus.nodejs.sh"
echo "bonus.nodejs.sh [on|off]"
exit 1
fi
@ -14,11 +14,13 @@ if ! grep -Eq "^nodeJS=" /mnt/hdd/raspiblitz.conf; then
echo "nodeJS=off" >> /mnt/hdd/raspiblitz.conf
fi
# check if nodeJS was installed
nodeJSInstalled=$(node -v 2>/dev/null | grep -c "v1.")
if ! [ ${nodeJSInstalled} -eq 0 ]; then
# switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# check if nodeJS was installed
nodeJSInstalled=$(node -v 2>/dev/null | grep -c "v1.")
if ! [ ${nodeJSInstalled} -eq 0 ]; then
echo "nodeJS is already installed"
else
else
# determine nodeJS VERSION and DISTRO
echo "Detect CPU architecture ..."
isARM=$(uname -m | grep -c 'arm')
@ -33,20 +35,16 @@ else
if [ ${isARM} -eq 1 ] ; then
DISTRO="linux-armv7l"
CHECKSUM="8fdf1751c985c4e8048b23bbe9e36aa0cad0011c755427694ea0fda9efad6d97"
fi
if [ ${isAARCH64} -eq 1 ] ; then
elif [ ${isAARCH64} -eq 1 ] ; then
DISTRO="linux-arm64"
CHECKSUM="8311f513a7d1911200502dd3e00142cef56d600c851d5870f68d939802205b73"
fi
if [ ${isX86_64} -eq 1 ] ; then
elif [ ${isX86_64} -eq 1 ] ; then
DISTRO="linux-x64"
CHECKSUM="1956e196e3c3c8ef5f0c45db76d7c1245af4ccdda2b7ab30a57ce91d6e165caa"
fi
if [ ${isX86_32} -eq 1 ] ; then
elif [ ${isX86_32} -eq 1 ] ; then
echo "FAIL: No X86 32bit build available - will abort setup"
exit 1
fi
if [ ${#DISTRO} -eq 0 ]; then
elif [ ${#DISTRO} -eq 0 ]; then
echo "FAIL: Was not able to determine architecture"
exit 1
fi
@ -71,7 +69,6 @@ else
fi
echo "OK CHECKSUM of nodeJS is OK"
sleep 3
# install
sudo mkdir -p /usr/local/lib/nodejs
sudo tar -xJvf node-$VERSION-$DISTRO.tar.xz -C /usr/local/lib/nodejs
@ -91,10 +88,22 @@ else
echo "ABORT - nodeJs install"
exit 1
fi
fi
# setting value in raspi blitz config
sudo sed -i "s/^nodeJS=.*/nodeJS=on/g" /mnt/hdd/raspiblitz.conf
echo "Installed nodeJS $(node -v)"
exit 0
fi
# setting value in raspi blitz config
sudo sed -i "s/^nodeJS=.*/nodeJS=on/g" /mnt/hdd/raspiblitz.conf
echo "Installed nodeJS $(node -v)"
exit 0
# switch off
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspiblitz config
sudo sed -i "s/^nodeJS=.*/nodeJS=off/g" /mnt/hdd/raspiblitz.conf
echo "*** REMOVING NODEJS ***"
sudo rm -rf /usr/local/lib/nodejs
echo "OK NodeJS removed."
exit 0
fi
echo "FAIL - Unknown Parameter $1"
exit 1