diff --git a/packager/debian/postinst b/packager/debian/postinst index e37fd104f..9a6a7834c 100755 --- a/packager/debian/postinst +++ b/packager/debian/postinst @@ -3,13 +3,13 @@ set -e adduser --quiet --system \ - --group --home /etc/pm2 \ - --gecos "PM2 Process Manager" pm2 + --group --home /etc/pm2 \ + --gecos "PM2 Process Manager" pm2 if hash systemctl 2> /dev/null; then { - systemctl enable "pm2.service" && \ - systemctl start "pm2.service" + systemctl enable "pm2.service" && \ + systemctl start "pm2.service" } || echo "pm2 could not be registered or started" elif hash service 2> /dev/null; then service "pm2" start || echo "pm2 could not be registered or started" diff --git a/packager/debian/prerm b/packager/debian/prerm index d9deb2446..3f94737a5 100755 --- a/packager/debian/prerm +++ b/packager/debian/prerm @@ -2,8 +2,8 @@ if hash systemctl 2> /dev/null; then systemctl disable "pm2.service" && \ - systemctl stop "pm2.service" || \ - echo "pm2 wasn't even running!" + systemctl stop "pm2.service" || \ + echo "pm2 wasn't even running!" elif hash service 2> /dev/null; then service "pm2" stop || echo "pm2 wasn't even running!" else diff --git a/packager/rhel/postinst b/packager/rhel/postinst index ed22be211..db38cb414 100755 --- a/packager/rhel/postinst +++ b/packager/rhel/postinst @@ -5,15 +5,15 @@ set -e mkdir -p /etc/pm2 adduser --system \ - --home-dir /etc/pm2 \ - --comment "PM2 Process Manager" pm2 + --home-dir /etc/pm2 \ + --comment "PM2 Process Manager" pm2 chown -R pm2:pm2 /etc/pm2 if hash systemctl 2> /dev/null; then { - systemctl enable "pm2.service" && \ - systemctl start "pm2.service" + systemctl enable "pm2.service" && \ + systemctl start "pm2.service" } || echo "pm2 could not be registered or started" elif hash service 2> /dev/null; then service "pm2" start || echo "pm2 could not be registered or started" diff --git a/packager/rhel/prerm b/packager/rhel/prerm index d9deb2446..3f94737a5 100755 --- a/packager/rhel/prerm +++ b/packager/rhel/prerm @@ -2,8 +2,8 @@ if hash systemctl 2> /dev/null; then systemctl disable "pm2.service" && \ - systemctl stop "pm2.service" || \ - echo "pm2 wasn't even running!" + systemctl stop "pm2.service" || \ + echo "pm2 wasn't even running!" elif hash service 2> /dev/null; then service "pm2" stop || echo "pm2 wasn't even running!" else diff --git a/packager/setup.deb.sh b/packager/setup.deb.sh index 4727b67fb..272d641b2 100755 --- a/packager/setup.deb.sh +++ b/packager/setup.deb.sh @@ -33,15 +33,15 @@ gpg_check () { echo "Checking for gpg..." if command -v gpg > /dev/null; then - echo "Detected gpg..." + echo "Detected gpg..." else - echo "Installing gnupg for GPG verification..." - apt-get install -y gnupg - if [ "$?" -ne "0" ]; then - echo "Unable to install GPG! Your base system has a problem; please check your default OS's package repositories because GPG should work." - echo "Repository installation aborted." - exit 1 - fi + echo "Installing gnupg for GPG verification..." + apt-get install -y gnupg + if [ "$?" -ne "0" ]; then + echo "Unable to install GPG! Your base system has a problem; please check your default OS's package repositories because GPG should work." + echo "Repository installation aborted." + exit 1 + fi fi } @@ -49,24 +49,24 @@ curl_check () { echo "Checking for curl..." if command -v curl > /dev/null; then - echo "Detected curl..." + echo "Detected curl..." else - echo "Installing curl..." - apt-get install -q -y curl - if [ "$?" -ne "0" ]; then - echo "Unable to install curl! Your base system has a problem; please check your default OS's package repositories because curl should work." - echo "Repository installation aborted." - exit 1 - fi + echo "Installing curl..." + apt-get install -q -y curl + if [ "$?" -ne "0" ]; then + echo "Unable to install curl! Your base system has a problem; please check your default OS's package repositories because curl should work." + echo "Repository installation aborted." + exit 1 + fi fi } install_debian_keyring () { if [ "${os}" = "debian" ]; then - echo "Installing debian-archive-keyring which is needed for installing " - echo "apt-transport-https on many Debian systems." - apt-get install -y debian-archive-keyring &> /dev/null + echo "Installing debian-archive-keyring which is needed for installing " + echo "apt-transport-https on many Debian systems." + apt-get install -y debian-archive-keyring &> /dev/null fi } @@ -74,44 +74,44 @@ install_debian_keyring () detect_os () { if [[ ( -z "${os}" ) && ( -z "${dist}" ) ]]; then - # some systems dont have lsb-release yet have the lsb_release binary and - # vice-versa - if [ -e /etc/lsb-release ]; then - . /etc/lsb-release - - if [ "${ID}" = "raspbian" ]; then - os=${ID} - dist=`cut --delimiter='.' -f1 /etc/debian_version` - else - os=${DISTRIB_ID} - dist=${DISTRIB_CODENAME} - - if [ -z "$dist" ]; then - dist=${DISTRIB_RELEASE} - fi - fi - - elif [ `which lsb_release 2>/dev/null` ]; then - dist=`lsb_release -c | cut -f2` - os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'` - - elif [ -e /etc/debian_version ]; then - # some Debians have jessie/sid in their /etc/debian_version - # while others have '6.0.7' - os=`cat /etc/issue | head -1 | awk '{ print tolower($1) }'` - if grep -q '/' /etc/debian_version; then - dist=`cut --delimiter='/' -f1 /etc/debian_version` - else - dist=`cut --delimiter='.' -f1 /etc/debian_version` - fi - - else - unknown_os - fi + # some systems dont have lsb-release yet have the lsb_release binary and + # vice-versa + if [ -e /etc/lsb-release ]; then + . /etc/lsb-release + + if [ "${ID}" = "raspbian" ]; then + os=${ID} + dist=`cut --delimiter='.' -f1 /etc/debian_version` + else + os=${DISTRIB_ID} + dist=${DISTRIB_CODENAME} + + if [ -z "$dist" ]; then + dist=${DISTRIB_RELEASE} + fi + fi + + elif [ `which lsb_release 2>/dev/null` ]; then + dist=`lsb_release -c | cut -f2` + os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'` + + elif [ -e /etc/debian_version ]; then + # some Debians have jessie/sid in their /etc/debian_version + # while others have '6.0.7' + os=`cat /etc/issue | head -1 | awk '{ print tolower($1) }'` + if grep -q '/' /etc/debian_version; then + dist=`cut --delimiter='/' -f1 /etc/debian_version` + else + dist=`cut --delimiter='.' -f1 /etc/debian_version` + fi + + else + unknown_os + fi fi if [ -z "$dist" ]; then - unknown_os + unknown_os fi # remove whitespace from OS and dist name @@ -164,31 +164,31 @@ main () curl_exit_code=$? if [ "$curl_exit_code" = "22" ]; then - echo "This script is unable to download the repository definition." - echo - [ -e $apt_source_path ] && rm $apt_source_path - unknown_os + echo "This script is unable to download the repository definition." + echo + [ -e $apt_source_path ] && rm $apt_source_path + unknown_os elif [ "$curl_exit_code" = "35" -o "$curl_exit_code" = "60" ]; then - echo "curl is unable to connect to packagecloud.io over TLS when running: " - echo " curl ${apt_config_url}" - echo "This is usually due to one of two things:" - echo - echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)" - echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version" - echo - echo "Contact support@packagecloud.io with information about your system for help." - [ -e $apt_source_path ] && rm $apt_source_path - exit 1 + echo "curl is unable to connect to packagecloud.io over TLS when running: " + echo " curl ${apt_config_url}" + echo "This is usually due to one of two things:" + echo + echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)" + echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version" + echo + echo "Contact support@packagecloud.io with information about your system for help." + [ -e $apt_source_path ] && rm $apt_source_path + exit 1 elif [ "$curl_exit_code" -gt "0" ]; then - echo - echo "Unable to run: " - echo " curl ${apt_config_url}" - echo - echo "Double check your curl installation and try again." - [ -e $apt_source_path ] && rm $apt_source_path - exit 1 + echo + echo "Unable to run: " + echo " curl ${apt_config_url}" + echo + echo "Double check your curl installation and try again." + [ -e $apt_source_path ] && rm $apt_source_path + exit 1 else - echo "done." + echo "done." fi echo -n "Importing packagecloud gpg key... " @@ -207,21 +207,21 @@ main () CURR_USER=$SUDO_USER if [ "$CURR_USER" == "" ]; then - CURR_USER=$USER + CURR_USER=$USER fi if [ "$CURR_USER" == "root" ] || [ "$CURR_USER" == "" ]; then - echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" - echo "WARNING: You are either running this script as root or the" - echo " \$USER variable is empty. In order to have a" - echo " working PM2 installation, you need to add your" - echo " user in the pm2 group using the following" - echo " command: usermod -aG pm2 " - echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" + echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" + echo "WARNING: You are either running this script as root or the" + echo " \$USER variable is empty. In order to have a" + echo " working PM2 installation, you need to add your" + echo " user in the pm2 group using the following" + echo " command: usermod -aG pm2 " + echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" else - echo -n "Adding $CURR_USER to group pm2..." - usermod -aG pm2 $CURR_USER - echo "done." + echo -n "Adding $CURR_USER to group pm2..." + usermod -aG pm2 $CURR_USER + echo "done." fi echo echo "Installation done." diff --git a/packager/setup.rpm.sh b/packager/setup.rpm.sh index 41cd707f8..b9791a39f 100755 --- a/packager/setup.rpm.sh +++ b/packager/setup.rpm.sh @@ -33,10 +33,10 @@ curl_check () { echo "Checking for curl..." if command -v curl > /dev/null; then - echo "Detected curl..." + echo "Detected curl..." else - echo "Installing curl..." - yum install -d0 -e0 -y curl + echo "Installing curl..." + yum install -d0 -e0 -y curl fi } @@ -44,60 +44,60 @@ curl_check () detect_os () { if [[ ( -z "${os}" ) && ( -z "${dist}" ) ]]; then - if [ -e /etc/os-release ]; then - . /etc/os-release - os=${ID} - if [ "${os}" = "poky" ]; then - dist=`echo ${VERSION_ID}` - elif [ "${os}" = "sles" ]; then - dist=`echo ${VERSION_ID}` - elif [ "${os}" = "opensuse" ]; then - dist=`echo ${VERSION_ID}` - else - dist=`echo ${VERSION_ID} | awk -F '.' '{ print $1 }'` - fi - - elif [ `which lsb_release 2>/dev/null` ]; then - # get major version (e.g. '5' or '6') - dist=`lsb_release -r | cut -f2 | awk -F '.' '{ print $1 }'` - - # get os (e.g. 'centos', 'redhatenterpriseserver', etc) - os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'` - - elif [ -e /etc/oracle-release ]; then - dist=`cut -f5 --delimiter=' ' /etc/oracle-release | awk -F '.' '{ print $1 }'` - os='ol' - - elif [ -e /etc/fedora-release ]; then - dist=`cut -f3 --delimiter=' ' /etc/fedora-release` - os='fedora' - - elif [ -e /etc/redhat-release ]; then - os_hint=`cat /etc/redhat-release | awk '{ print tolower($1) }'` - if [ "${os_hint}" = "centos" ]; then - dist=`cat /etc/redhat-release | awk '{ print $3 }' | awk -F '.' '{ print $1 }'` - os='centos' - elif [ "${os_hint}" = "scientific" ]; then - dist=`cat /etc/redhat-release | awk '{ print $4 }' | awk -F '.' '{ print $1 }'` - os='scientific' - else - dist=`cat /etc/redhat-release | awk '{ print tolower($7) }' | cut -f1 --delimiter='.'` - os='redhatenterpriseserver' - fi - - else - aws=`grep -q Amazon /etc/issue` - if [ "$?" = "0" ]; then - dist='6' - os='aws' - else - unknown_os - fi - fi + if [ -e /etc/os-release ]; then + . /etc/os-release + os=${ID} + if [ "${os}" = "poky" ]; then + dist=`echo ${VERSION_ID}` + elif [ "${os}" = "sles" ]; then + dist=`echo ${VERSION_ID}` + elif [ "${os}" = "opensuse" ]; then + dist=`echo ${VERSION_ID}` + else + dist=`echo ${VERSION_ID} | awk -F '.' '{ print $1 }'` + fi + + elif [ `which lsb_release 2>/dev/null` ]; then + # get major version (e.g. '5' or '6') + dist=`lsb_release -r | cut -f2 | awk -F '.' '{ print $1 }'` + + # get os (e.g. 'centos', 'redhatenterpriseserver', etc) + os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'` + + elif [ -e /etc/oracle-release ]; then + dist=`cut -f5 --delimiter=' ' /etc/oracle-release | awk -F '.' '{ print $1 }'` + os='ol' + + elif [ -e /etc/fedora-release ]; then + dist=`cut -f3 --delimiter=' ' /etc/fedora-release` + os='fedora' + + elif [ -e /etc/redhat-release ]; then + os_hint=`cat /etc/redhat-release | awk '{ print tolower($1) }'` + if [ "${os_hint}" = "centos" ]; then + dist=`cat /etc/redhat-release | awk '{ print $3 }' | awk -F '.' '{ print $1 }'` + os='centos' + elif [ "${os_hint}" = "scientific" ]; then + dist=`cat /etc/redhat-release | awk '{ print $4 }' | awk -F '.' '{ print $1 }'` + os='scientific' + else + dist=`cat /etc/redhat-release | awk '{ print tolower($7) }' | cut -f1 --delimiter='.'` + os='redhatenterpriseserver' + fi + + else + aws=`grep -q Amazon /etc/issue` + if [ "$?" = "0" ]; then + dist='6' + os='aws' + else + unknown_os + fi + fi fi if [[ ( -z "${os}" ) || ( -z "${dist}" ) ]]; then - unknown_os + unknown_os fi # remove whitespace from OS and dist name @@ -113,25 +113,25 @@ finalize_yum_repo () yum install -y pygpgme --disablerepo='Keymetrics_pm2' pypgpme_check=`rpm -qa | grep -qw pygpgme` if [ "$?" != "0" ]; then - echo - echo "WARNING: " - echo "The pygpgme package could not be installed. This means GPG verification is not possible for any RPM installed on your system. " - echo "To fix this, add a repository with pygpgme. Usualy, the EPEL repository for your system will have this. " - echo "More information: https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F" - echo - - # set the repo_gpgcheck option to 0 - sed -i'' 's/repo_gpgcheck=1/repo_gpgcheck=0/' /etc/yum.repos.d/Keymetrics_pm2.repo + echo + echo "WARNING: " + echo "The pygpgme package could not be installed. This means GPG verification is not possible for any RPM installed on your system. " + echo "To fix this, add a repository with pygpgme. Usualy, the EPEL repository for your system will have this. " + echo "More information: https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F" + echo + + # set the repo_gpgcheck option to 0 + sed -i'' 's/repo_gpgcheck=1/repo_gpgcheck=0/' /etc/yum.repos.d/Keymetrics_pm2.repo fi echo "Installing yum-utils..." yum install -y yum-utils --disablerepo='Keymetrics_pm2' yum_utils_check=`rpm -qa | grep -qw yum-utils` if [ "$?" != "0" ]; then - echo - echo "WARNING: " - echo "The yum-utils package could not be installed. This means you may not be able to install source RPMs or use other yum features." - echo + echo + echo "WARNING: " + echo "The yum-utils package could not be installed. This means you may not be able to install source RPMs or use other yum features." + echo fi echo "Generating yum cache for Keymetrics_pm2..." @@ -156,21 +156,21 @@ install_pm2 () CURR_USER=$SUDO_USER if [ "$CURR_USER" == "" ]; then - CURR_USER=$USER + CURR_USER=$USER fi if [ "$CURR_USER" == "root" ] || [ "$CURR_USER" == "" ]; then - echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" - echo "WARNING: You are either running this script as root or the" - echo " \$USER variable is empty. In order to have a" - echo " working PM2 installation, you need to add your" - echo " user in the pm2 group using the following" - echo " command: usermod -aG pm2 " - echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" + echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" + echo "WARNING: You are either running this script as root or the" + echo " \$USER variable is empty. In order to have a" + echo " working PM2 installation, you need to add your" + echo " user in the pm2 group using the following" + echo " command: usermod -aG pm2 " + echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" else - echo -n "Adding $CURR_USER to group pm2..." - usermod -aG pm2 $CURR_USER - echo "done." + echo -n "Adding $CURR_USER to group pm2..." + usermod -aG pm2 $CURR_USER + echo "done." fi } @@ -183,10 +183,10 @@ main () yum_repo_config_url="https://packagecloud.io/install/repositories/$REPOSITORY_OWNER/pm2/config_file.repo?os=${os}&dist=${dist}&source=script" if [ "${os}" = "sles" ] || [ "${os}" = "opensuse" ]; then - yum_repo_path=/etc/zypp/repos.d/Keymetrics_pm2.repo + yum_repo_path=/etc/zypp/repos.d/Keymetrics_pm2.repo else - yum_repo_path=/etc/yum.repos.d/Keymetrics_pm2.repo - install_node + yum_repo_path=/etc/yum.repos.d/Keymetrics_pm2.repo + install_node fi echo "Downloading repository file: ${yum_repo_config_url}" @@ -195,53 +195,53 @@ main () curl_exit_code=$? if [ "$curl_exit_code" = "22" ]; then - echo - echo - echo -n "Unable to download repo config from: " - echo "${yum_repo_config_url}" - echo - echo "This usually happens if your operating system is not supported by " - echo "packagecloud.io, or this script's OS detection failed." - echo - echo "You can override the OS detection by setting os= and dist= prior to running this script." - echo "You can find a list of supported OSes and distributions on our website: https://packagecloud.io/docs#os_distro_version" - echo - echo "For example, to force CentOS 6: os=el dist=6 ./script.sh" - echo - echo "If you are running a supported OS, please email support@packagecloud.io and report this." - [ -e $yum_repo_path ] && rm $yum_repo_path - exit 1 + echo + echo + echo -n "Unable to download repo config from: " + echo "${yum_repo_config_url}" + echo + echo "This usually happens if your operating system is not supported by " + echo "packagecloud.io, or this script's OS detection failed." + echo + echo "You can override the OS detection by setting os= and dist= prior to running this script." + echo "You can find a list of supported OSes and distributions on our website: https://packagecloud.io/docs#os_distro_version" + echo + echo "For example, to force CentOS 6: os=el dist=6 ./script.sh" + echo + echo "If you are running a supported OS, please email support@packagecloud.io and report this." + [ -e $yum_repo_path ] && rm $yum_repo_path + exit 1 elif [ "$curl_exit_code" = "35" -o "$curl_exit_code" = "60" ]; then - echo - echo "curl is unable to connect to packagecloud.io over TLS when running: " - echo " curl ${yum_repo_config_url}" - echo - echo "This is usually due to one of two things:" - echo - echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)" - echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version" - echo - echo "Contact support@packagecloud.io with information about your system for help." - [ -e $yum_repo_path ] && rm $yum_repo_path - exit 1 + echo + echo "curl is unable to connect to packagecloud.io over TLS when running: " + echo " curl ${yum_repo_config_url}" + echo + echo "This is usually due to one of two things:" + echo + echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)" + echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version" + echo + echo "Contact support@packagecloud.io with information about your system for help." + [ -e $yum_repo_path ] && rm $yum_repo_path + exit 1 elif [ "$curl_exit_code" -gt "0" ]; then - echo - echo "Unable to run: " - echo " curl ${yum_repo_config_url}" - echo - echo "Double check your curl installation and try again." - [ -e $yum_repo_path ] && rm $yum_repo_path - exit 1 + echo + echo "Unable to run: " + echo " curl ${yum_repo_config_url}" + echo + echo "Double check your curl installation and try again." + [ -e $yum_repo_path ] && rm $yum_repo_path + exit 1 else - echo "done." + echo "done." fi if [ "${os}" = "sles" ] || [ "${os}" = "opensuse" ]; then - finalize_zypper_repo - install_pm2 zypper + finalize_zypper_repo + install_pm2 zypper else - finalize_yum_repo - install_pm2 yum + finalize_yum_repo + install_pm2 yum fi echo