Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Litespeed installer needs updated. #1

Open
alaskan-hippie opened this issue Jul 2, 2017 · 2 comments
Open

Litespeed installer needs updated. #1

alaskan-hippie opened this issue Jul 2, 2017 · 2 comments
Assignees

Comments

@alaskan-hippie
Copy link

The Litespeed installer is quite simple, and doesn't check for incompatibilities or errors.

First, Litespeed is not compatible with a DSO/mod_ruid2 setup so you'll want to add a check for that, and maybe an option to 'remove automatically' upon confirmation. Something like this would work to check for, and allow pre-removal of the moodules on a cPanel/ea4 server

echo "Checking for module conflicts"
sleep 0.5
mods=($(httpd -M 2>/dev/null | grep -Eo '(php.*|ruid2)_module' ))

if [ ${#mods[@]} -eq 2 ]; then
__conflict="2"
elif [ ${#mods[@]} -eq 1 ]; then
__conflict="1"
elif [${#mods[@]} -eq 0 ]; then
__conflict="N"
fi

echo -e "$__conflict"
ynq="Y"
if [[ "$__conflict" == "2" ]]; then
echo "Your server contains the following modules which conflict with Litespeed."
printf '%s\n' "${mods[@]}"
read -e -p "Would you like to uninstall them? (Y/n/q) " ynq
elif [[ "$__conflict" == "1" ]] ; then
echo "Your server contains the following module which conflicts with Litespeed."
printf '%s\n' "${mods[@]}"
read -e -p "Would you like to uninstall this? (Y/n/q) " ynq
elif [[ "$__conflict" == "N" ]]; then
echo "No module conflicts. Proceeding"
fi

if [[ $ynq =~ ^(Y|y| ) ]] | [ -z $response ]; then
ynq="Y"
fi

case $ynq in
[Yy] ) echo "removal command here";;
[Nn] ) echo "can't continue, exit"; exit 1;;
[Qq] ) echo "exiting" ; exit 1 ;;
* ) echo "unrecognized option; exiting"; exit 2 ;;
esac
`

The following will remove the modules on a cPanel EasyApache 4 system

yum remove ea-php{54,55,56,70,71}-php ea-apache24-mod_ruid2

To do this on a cPanel EA3 system would require more manual intervention (via easyapache rebuild). Any other server/system type would need special attention which is outside the scope of the PoC above.

Next, typical installations would either fall into two groups: Install along side apache; or install replacing apache. Something like the following should be used as a more "smart" install method (note "echo" was placed on the line that actually does the installation to prevent accidental firing during testing; remove in production):

printf "Litespeed can be installed along side Apache [1], or as a relacement for Apache [2].\n"``read -p "With which method would you like to proceed? (1/2/q) " inst_meth

if [[ $inst_meth =~ ^(1| ) ]] | [ -z $inst_meth ]; then
local inst_meth="1"
fi

case $inst_meth in
1 ) echo "Installing along side Apache now, with a port offset of 1000"; __portoff="1000";;
2 ) echo "Installing as replacement for Apache now"; __portoff="0";;
q ) echo "quitting"; exit 1;;
esac

install_lsws () {
trap "{ cd ; rm -rf $TDIR; exit 255; }" EXIT INT QUIT
TDIR="/usr/local/src/lsws_install"

if [[ ! -d $TDIR ]]; then mkdir -p $TDIR; fi

wget --quiet http://www.litespeedtech.com/packages/cpanel/lsws_whm_autoinstaller.sh -O $TDIR/lsws_whm_autoinstaller.sh

chmod u+x $TDIR/lsws_whm_autoinstaller.sh

read -p "Please provide the license key: " __lic
read -p "Please provide the admin password: " __adpass
echo -e /usr/bin/bash $TDIR/lsws_whm_autoinstaller.sh $__lic 2 $__portoff admin $__adpass root@localhost 1 1

unset __portoff
}

install_lsws
exit 0

Note, my trap statement in the snippet above didn't actually work in my tests, so that will need adjusted, but you definitely want a temporary working directory for any installers, just in case.

Finally, you'll want to make sure Litespeed is actually up, and confirm Apache is in a state that you desired:

/usr/local/lsws/bin/lswsctrl status
/usr/local/apache/bin/apachectl status

If the server is using some sort of process monitor (such as LFD) you'll want to whitelist lshttpd (and lsphp as needed, it isn't always required, and in some cases is a very bad thing to do, so play that case-by-case). For example, with CSF/LFD:

echo "pexe:/usr/local/lsws/bin/lshttpd.*" >> /etc/csf/csf.pignore
csf -r; service lfd restart

Hope this helps.

@KeiroD KeiroD self-assigned this Jul 2, 2017
@KeiroD
Copy link
Owner

KeiroD commented Jul 2, 2017

Hello!

Thank you for contributing to Eidolos! I will be merging the code you submitted here after I've tested this on my test server and integrated it.

This may take a few days to make happen but it will happen. Regarding the recommendation for temporary directories for installers -- that is a good call. I will be working out a solution for this or otherwise work with you on this.

@alaskan-hippie
Copy link
Author

Sounds good. As I get more time for personal development work, I'll see what I can do to help further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants