Edit file File name : install.sh Content :#!/bin/bash SUDO_TEST=$(set) setup(){ set -o errexit set -o errtrace set -o nounset set -o pipefail } check_environment(){ operating_system=$(uname -s) if [ ! "${operating_system}" == "Linux" ]; then echo "Fatal error: your operating system is not supported." exit 1 fi if echo ${SUDO_TEST} | grep SUDO >/dev/null; then echo -e "\nYou are using SUDO , please run as root user...\n" echo -e "\nIf you don't have direct access to root user, please run \e[31msudo su -\e[39m command (do NOT miss the \e[31m-\e[39m at end or it will fail) and then run installation command again." exit 1 fi if [[ $(id -u) != 0 ]] >/dev/null; then echo -e "\nYou must use root user.\n" exit 1 fi if [ $# -eq 0 ]; then echo "Please include your serial no when running this script, i.e. bash install.sh 123456789. To request a trial key, use bash install.sh TRIAL" exit 1 fi if [ -f /usr/local/lsws/bin/lswsctrl ]; then echo "Fatal error: found Litespeed is already installed. Refusing to install a second time." exit 1 fi } Base_DownloadTrialKey() { curl -s -S -o trial.key "${1}" } Base_GetTrialKey() { local LICENSE_SITE="https://license.litespeedtech.com/reseller/trial.key" local LICENSE_SITE_2="https://license2.litespeedtech.com/reseller/trial.key" if ! Base_DownloadTrialKey $LICENSE_SITE; then Base_DownloadTrialKey $LICENSE_SITE_2 fi } dl_whm_installer(){ curl -s -S -o "lsws_whm_autoinstaller.sh" https://cpanel.litespeed.sh chmod a+x lsws_whm_autoinstaller.sh } dl_plesk_installer(){ curl -s -S -o "lsws_plesk_autoinstaller.sh" https://plesk.litespeed.sh chmod a+x lsws_plesk_autoinstaller.sh } run_installers(){ admin_pass=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 ; echo '') if [ -d "/etc/httpd/conf/plesk.conf.d/" ] || [ -d "/etc/apache2/plesk.conf.d/" ]; then is_plesk=1 else is_plesk=0 fi if [ -d "/usr/local/cpanel" ] && [ -f "./lsws.options" ]; then . ./lsws.options dl_whm_installer ./lsws_whm_autoinstaller.sh "$1" "${php_suexec}" "${port_offset}" "${admin_user}" "${admin_pass}" "${admin_email}" "${easyapache_integration}" "${auto_switch_to_lsws}" "${deploy_lscwp}" echo "Install finished! Your randomly generated admin password for the LiteSpeed WebAdmin interface is ${admin_pass}" echo "Please make sure to save this password." elif [ -d "/usr/local/cpanel" ] && [ ! -f "./lsws.options" ]; then echo "Could not find an lsws.options file. We will ask you for your preferred settings instead, but for automated bulk provisioning, you may want to exit and create an lsws.options file." read -p "Continue installer? (y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 read -p "Enable PHP_SUEXEC. Run PHP processes as the account owner. Available values: 0 (off), 1 (on), and 2 (user home directory only). Default value is 2: " php_suexec php_suexec="${php_suexec:=2}" read -p "Apache port offset. Run LiteSpeed in parallel with Apache. For example, if set to 1000, Apache will listen on port 80, and LiteSpeed on 1080. If set to 0, Apache and LiteSpeed will use the same port, and LiteSpeed will not automatically start after installation. Default value is 1000: " port_offset port_offset="${port_offset:=1000}" read -p "Admin username. For accessing LiteSpeed WebAdmin console. Default value is admin: " admin_user admin_user="${admin_user:=admin}" read -p "Admin email address. Receive important server notices, such as license expiration and server core dumps. Default value is root@localhost: " admin_email admin_email="${admin_email:=root@localhost}" read -p "EasyApache integration. Automatically rebuild matching PHP for LiteSpeed under EasyApache 3. Does nothing under EasyApache 4. Available values are 1 (enable) and 0 (disable). Default value is 1: " easyapache_integration easyapache_integration="${easyapache_integration:=1}" read -p "Switch to LiteSpeed Web Server. Automatically switches at the end of the installation if the port offset is set to 0. Available values are 1 (enable) and 0 (disable). Default value is 0: " auto_switch_to_lsws auto_switch_to_lsws="${auto_switch_to_lsws:=0}" read -p "Deploy LSCWP Automatically. Scans for Wordpress Websites on server and installs LSCache Plugin on them, Automatically sets up Cache Root. Available values are 1 (enable) and 0 (disable). Default value is 0: " deploy_lscwp deploy_lscwp="${deploy_lscwp:=0}" dl_whm_installer ./lsws_whm_autoinstaller.sh "$1" "${php_suexec}" "${port_offset}" "${admin_user}" "${admin_pass}" "${admin_email}" "${easyapache_integration}" "${auto_switch_to_lsws}" "${deploy_lscwp}" echo "Install finished! Your randomly generated admin password for the LiteSpeed WebAdmin interface is ${admin_pass}" echo "Please make sure to save this password." elif [[ $is_plesk -eq 1 ]] && [[ -f "./lsws.options" ]]; then . ./lsws.options dl_plesk_installer ./lsws_plesk_autoinstaller.sh "$1" "${php_suexec}" "${port_offset}" "${admin_user}" "${admin_pass}" "${admin_email}" "${auto_switch_php}" "${auto_switch_to_lsws}" echo "Install finished! Your randomly generated admin password for the LiteSpeed WebAdmin interface is ${admin_pass}" echo "Please make sure to save this password." elif [[ $is_plesk -eq 1 ]] && [[ ! -f "./lsws.options" ]]; then echo "Could not find an lsws.options file. We will ask you for your preferred settings instead, but for automated bulk provisioning, you may want to exit and create an lsws.options file." read -p "Continue installer? (y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 read -p "Enable PHP_SUEXEC. Run PHP processes as the account owner. Available values: 0 (off), 1 (on), and 2 (user home directory only). Default value is 2: " php_suexec php_suexec="${php_suexec:=2}" read -p "Apache port offset. Run LiteSpeed in parallel with Apache. For example, if set to 1000, Apache will listen on port 80, and LiteSpeed on 1080. If set to 0, Apache and LiteSpeed will use the same port, and LiteSpeed will not automatically start after installation. Default value is 1000: " port_offset port_offset="${port_offset:=2}" read -p "Admin username. For accessing LiteSpeed WebAdmin console. Default value is admin: " admin_user admin_user="${admin_user:=admin}" read -p "Admin email address. Receive important server notices, such as license expiration and server core dumps. Default value is root@localhost: " admin_email admin_email="${admin_email:=root@localhost}" read -p "Switch PHP Handlers. Automatically switch PHP handlers for users and/or subscriptions inside of Plesk. Available values: 0 (No change), 1 (Switch just for users), 2 (Switch just for subscriptions), 3 (Switch for both users and subscriptions). Default value is 0: " auto_switch_php auto_switch_php="${auto_switch_php:=0}" read -p "Switch to LiteSpeed Web Server. Automatically switches at the end of the installation if the port offset is set to 0. Available values are 1 (enable) and 0 (disable): " auto_switch_to_lsws auto_switch_to_lsws="${auto_switch_to_lsws:=0}" dl_plesk_installer ./lsws_plesk_autoinstaller.sh "$1" "${php_suexec}" "${port_offset}" "${admin_user}" "${admin_pass}" "${admin_email}" "${auto_switch_php}" "${auto_switch_to_lsws}" echo "Install finished! Your randomly generated admin password for the LiteSpeed WebAdmin interface is ${admin_pass}" echo "Please make sure to save this password." # For DirectAdmin, we don't have a similar installer as cPanel, but we can do everything using the command line rather than GUI. # Customization is more bare-bones in the absense of an autoinstaller like cPanel has. elif [ -d "/usr/local/directadmin" ] && [ -f "./lsws.options" ]; then . ./lsws.options cd /usr/local/directadmin/custombuild ./build update ./build set webserver litespeed ./build set mod_ruid2 no if [[ $1 == "TRIAL" ]] || [[ $1 == "trial" ]] ; then ./build set litespeed_serialno trial else ./build set litespeed_serialno $1 fi ./build set php1_mode lsphp ./build set php1_release ${php_version_default} ./build set php2_mode lsphp ./build set php2_release ${php_version_second} ./build set php3_mode lsphp ./build set php3_release ${php_version_third} ./build set php4_mode lsphp ./build set php4_release ${php_version_fourth} ./build litespeed ./build php n echo "Install finished! Your randomly generated admin password for the LiteSpeed WebAdmin interface is `grep -m1 '^litespeedadmin=' | cut -d= -f2`" echo "Please make sure to save this password." elif [ -d "/usr/local/directadmin" ] && [ ! -f "./lsws.options" ]; then echo "Could not find an lsws.options file. We will ask you for your preferred settings instead, but for automated bulk provisioning, you may want to exit and create an lsws.options file." read -p "Continue installer? (y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 read -p "Which PHP version would be the default? You'll get the option to install more PHP versions below. Available values: 7.4, 8.0, 8.1 Default value is 8.1: " php_version_default php_version_default="${php_version_default:=8.1}" read -p "Would you like to install second PHP version? Available values: 7.4, 8.0, 8.1, no. Default value is no, Just press enter or write no to not install a second php version: " php_version_second php_version_second="${php_version_second:=no}" read -p "Would you like to install third PHP version? Available values: 7.4, 8.0, 8.1, no. Default value is no, Just press enter or write no to not install a third php version: " php_version_third php_version_third="${php_version_third:=no}" read -p "Would you like to install fourth PHP version? Available values: 7.4, 8.0, 8.1, no. Default value is no, Just press enter or write no to not install a fourth php version: " php_version_fourth php_version_fourth="${php_version_fourth:=no}" cd /usr/local/directadmin/custombuild ./build update ./build set webserver litespeed ./build set mod_ruid2 no if [[ $1 == "TRIAL" ]] || [[ $1 == "trial" ]] ; then ./build set litespeed_serialno trial else ./build set litespeed_serialno $1 fi ./build set php1_mode lsphp ./build set php1_release ${php_version_default} ./build set php2_mode lsphp ./build set php2_release ${php_version_second} ./build set php3_mode lsphp ./build set php3_release ${php_version_third} ./build set php4_mode lsphp ./build set php4_release ${php_version_fourth} ./build litespeed ./build php n echo "Install finished! Your randomly generated admin password for the LiteSpeed WebAdmin interface is `grep -m1 '^litespeedadmin=' | cut -d= -f2`" echo "Please make sure to save this password." else latest_version=$(curl -s -S http://update.litespeedtech.com/ws/latest.php | head -n 1 | sed -nre 's/^[^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p') major_version=$(echo "${latest_version}" | cut -c 1) bitness=$(uname -m) if [ "${bitness}" == "i686" ]; then bitness="i386" fi rm -f lsws-latest.tar.gz rm -rf "lsws-${latest_version}" curl -s -S -o "lsws-latest.tar.gz" https://www.litespeedtech.com/packages/"${major_version}".0/lsws-"${latest_version}"-ent-"${bitness}"-linux.tar.gz tar -xzf "lsws-latest.tar.gz" cd "lsws-${latest_version}" if [[ "${1}" == "TRIAL" ]] || [[ "${1}" == "trial" ]] ; then Base_GetTrialKey else echo "${1}" > serial.no fi bash "./install.sh" fi } main(){ setup check_environment "$@" run_installers "$@" } main "$@" exit 0 Save