tidy up node update function

This commit is contained in:
ronivay
2021-05-03 14:58:18 +03:00
parent 3757cad406
commit 15cc82ff8a

View File

@@ -307,57 +307,58 @@ function InstallDependenciesDeb {
function UpdateNodeYarn { function UpdateNodeYarn {
if [[ $AUTOUPDATE == "true" ]]; then if [[ $AUTOUPDATE != "true" ]]; then
return 0
fi
if [ $PKG_FORMAT == "rpm" ]; then echo
printinfo "Checking current node.js version"
NODEV=$(node -v 2>/dev/null| grep -Eo '[0-9.]+' | cut -d'.' -f1)
if [ $PKG_FORMAT == "rpm" ]; then
if [[ -n $NODEV ]] && [[ $NODEV -lt ${NODEVERSION} ]]; then
echo echo
printinfo "Checking current node.js version" printprog "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"
NODEV=$(node -v 2>/dev/null| grep -Eo '[0-9.]+' | cut -d'.' -f1) cmdlog "curl -sL https://rpm.nodesource.com/setup_${NODEVERSION}.x | bash -"
if [[ -n $NODEV ]] && [[ $NODEV -lt ${NODEVERSION} ]]; then curl -sL https://rpm.nodesource.com/setup_${NODEVERSION}.x | bash - >>$LOGFILE 2>&1
echo cmdlog "yum clean all"
printprog "node.js version is $NODEV, upgrading to ${NODEVERSION}.x" yum clean all >> $LOGFILE 2>&1
cmdlog "curl -sL https://rpm.nodesource.com/setup_${NODEVERSION}.x | bash -" cmdlog "yum install -y nodejs"
curl -sL https://rpm.nodesource.com/setup_${NODEVERSION}.x | bash - >>$LOGFILE 2>&1 yum install -y nodejs >>LOGFILE 2>&1
cmdlog "yum clean all" printok "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"
yum clean all >> $LOGFILE 2>&1
cmdlog "yum install -y nodejs"
yum install -y nodejs >>LOGFILE 2>&1
printok "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"
else
if [[ "$TASK" == "Update" ]]; then
echo
printprog "node.js version already on $NODEV, checking updates"
cmdlog "yum update -y nodejs yarn"
yum update -y nodejs yarn >>$LOGFILE 2>&1
printok "node.js version already on $NODEV, checking updates"
elif [[ "$TASK" == "Installation" ]]; then
echo
printinfo "node.js version already on $NODEV"
fi
fi
else else
echo if [[ "$TASK" == "Update" ]]; then
printinfo "Checking current node.js version"
NODEV=$(node -v 2>/dev/null| grep -Eo '[0-9.]+' | cut -d'.' -f1)
if [[ -n $NODEV ]] && [[ $NODEV -lt ${NODEVERSION} ]]; then
echo echo
printprog "node.js version is $NODEV, upgrading to ${NODEVERSION}.x" printprog "node.js version already on $NODEV, checking updates"
cmdlog "curl -sL https://deb.nodesource.com/setup_${NODEVERSION}.x | bash -" cmdlog "yum update -y nodejs yarn"
curl -sL https://deb.nodesource.com/setup_${NODEVERSION}.x | bash - >>$LOGFILE 2>&1 yum update -y nodejs yarn >>$LOGFILE 2>&1
cmdlog "apt-get install -y nodejs" printok "node.js version already on $NODEV, checking updates"
apt-get install -y nodejs >>$LOGFILE 2>&1 elif [[ "$TASK" == "Installation" ]]; then
printok "node.js version is $NODEV, upgrading to ${NODEVERSION}.x" echo
else printinfo "node.js version already on $NODEV"
if [[ "$TASK" == "Update" ]]; then fi
echo fi
printprog "node.js version already on $NODEV, checking updates" fi
cmdlog "apt-get install -y --only-upgrade nodejs yarn"
apt-get install -y --only-upgrade nodejs yarn >>$LOGFILE 2>&1 if [ $PKG_FORMAT == "deb" ]]; then
printok "node.js version already on $NODEV, checking updates" if [[ -n $NODEV ]] && [[ $NODEV -lt ${NODEVERSION} ]]; then
elif [[ "$TASK" == "Installation" ]]; then echo
echo printprog "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"
printinfo "node.js version already on $NODEV" cmdlog "curl -sL https://deb.nodesource.com/setup_${NODEVERSION}.x | bash -"
fi curl -sL https://deb.nodesource.com/setup_${NODEVERSION}.x | bash - >>$LOGFILE 2>&1
cmdlog "apt-get install -y nodejs"
apt-get install -y nodejs >>$LOGFILE 2>&1
printok "node.js version is $NODEV, upgrading to ${NODEVERSION}.x"
else
if [[ "$TASK" == "Update" ]]; then
echo
printprog "node.js version already on $NODEV, checking updates"
cmdlog "apt-get install -y --only-upgrade nodejs yarn"
apt-get install -y --only-upgrade nodejs yarn >>$LOGFILE 2>&1
printok "node.js version already on $NODEV, checking updates"
elif [[ "$TASK" == "Installation" ]]; then
echo
printinfo "node.js version already on $NODEV"
fi fi
fi fi
fi fi