fix pm2 install needing sudo

This commit is contained in:
Your Name 2019-11-27 08:37:51 -06:00
parent 7d7ec1a00b
commit db9176c284

View File

@ -91,14 +91,30 @@ function verlt() { [ "$1" = "$2" ] && return 1 || verlte $1 $2 ;}
# Update before first apt-get
if [ $mac != 'Darwin' ]; then
echo -e "\e[96mUpdating packages ...\e[90m" | tee -a $logfile
sudo apt-get update || echo -e "\e[91mUpdate failed, carrying on installation ...\e[90m" | tee -a $logfile
fi
echo -e "\e[96mUpdating packages ...\e[90m" | tee -a $logfile
update=$(sudo apt-get update 2>&1)
echo $update >> $logfile
update_rc=$?
if [ $update_rc -ne 0 ]; then
echo -e "\e[91mUpdate failed, retrying installation ...\e[90m" | tee -a $logfile
if [ $(echo $update | grep "apt-secure" | wc -l) -eq 1 ]; then
update=$(sudo apt-get update --allow-releaseinfo-change 2>&1)
echo $update >> $logfile
update_rc=$?
if [ $update_rc -ne 0 ]; then
echo "second apt-get update failed" $update | ree -a $logfile
exit 1
else
echo "second apt-get update completed ok" >> $logfile
fi
fi
else
echo "apt-get update completed ok" >> $logfile
fi
if [ $mac != 'Darwin' ]; then
# Installing helper tools
echo -e "\e[96mInstalling helper tools ...\e[90m" | tee -a $logfile
sudo apt-get --assume-yes install curl wget git build-essential unzip || exit
# Installing helper tools
echo -e "\e[96mInstalling helper tools ...\e[90m" | tee -a $logfile
sudo apt-get --assume-yes install curl wget git build-essential unzip || exit
fi
# Check if we need to install or upgrade Node.js.
@ -122,6 +138,7 @@ if command_exists node; then
if pgrep "node" > /dev/null; then
echo -e "\e[91mA Node process is currently running. Can't upgrade." | tee -a $logfile
echo "Please quit all Node processes and restart the installer." | tee -a $logfile
echo $(ps -ef | grep node | grep -v \-\-color) | tee -a $logfile
exit;
fi
@ -220,11 +237,11 @@ if $NPM_INSTALL; then
#
# if this is a mac, npm was installed with node
if [ $mac != 'Darwin' ]; then
sudo apt-get install -y npm
sudo apt-get install -y npm >>$logfile
fi
# update to the latest.
echo upgrading npm to latest >> $logfile
sudo npm i -g npm
sudo npm i -g npm >>$logfile
echo -e "\e[92mnpm installation Done! version=V$(npm -v)\e[0m" | tee -a $logfile
fi
@ -329,7 +346,7 @@ if [[ $choice =~ ^[Yy]$ ]]; then
if [ "$pm2_installed." == "." ]; then
# install it.
echo pm2 not installed, installing >>$logfile
result=$(npm install $up -g pm2)
result=$(sudo npm install $up -g pm2 2>&1)
echo pm2 install result $result >>$logfile
# if this is a mac
if [ $mac == 'Darwin' ]; then