Install script fixes

main
Yasen Pramatarov 2024-07-19 11:14:30 +03:00
parent 7e5e68dc23
commit 6596e97889
1 changed files with 89 additions and 54 deletions

View File

@ -1,43 +1,45 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo "Jilo-Web install script" echo "Jilo-Web deployment script"
# enter domain function install() {
read -p "Domain name for the web service [localhost]: " DOMAIN
DOMAIN=${DOMAIN:-localhost}
# enter folder # enter domain
read -p "Web subfolder [jilo-web]: " WEB_DIR read -p "Domain name for the web service [localhost]: " DOMAIN
WEB_DIR=${WEB_DIR:-jilo-web} DOMAIN=${DOMAIN:-localhost}
INSTALL_DIR="/opt/jilo-web/public_html" # enter folder
DOC_DIR="/opt/jilo-web/doc" read -p "Web subfolder [jilo-web]: " WEB_DIR
ETC_DIR="/opt/jilo-web/etc" WEB_DIR=${WEB_DIR:-jilo-web}
mkdir -p $INSTALL_DIR INSTALL_DIR="/opt/jilo-web/public_html"
cp -r ./public_html/* $INSTALL_DIR DOC_DIR="/opt/jilo-web/doc"
ETC_DIR="/opt/jilo-web/etc"
mkdir -p $DOC_DIR mkdir -p $INSTALL_DIR
cp CHANGELOG.md $DOC_DIR cp -r ./public_html/* $INSTALL_DIR
cp LICENSE $DOC_DIR
cp README.md $DOC_DIR
cp TODO.md $DOC_DIR
cp config.apache $DOC_DIR
cp config.nginx $DOC_DIR
mkdir -p $ETC_DIR mkdir -p $DOC_DIR
cp jilo-web.conf.php $ETC_DIR cp CHANGELOG.md $DOC_DIR
cp jilo-web.schema $ETC_DIR cp LICENSE $DOC_DIR
cp README.md $DOC_DIR
cp TODO.md $DOC_DIR
cp config.apache $DOC_DIR
cp config.nginx $DOC_DIR
#FIXME mkdir -p $ETC_DIR
#mkdir -p "jilo-web-$VERSION/usr/share/man/man8" cp jilo-web.conf.php $ETC_DIR
#cp ../man-jilo-web.8 "jilo-web-$VERSION/usr/share/man/man8/jilo-web.8" cp jilo-web.schema $ETC_DIR
# we need a webserver, check for Apache and Nginx #FIXME
WEB_SERVER="" #mkdir -p "jilo-web-$VERSION/usr/share/man/man8"
#cp ../man-jilo-web.8 "jilo-web-$VERSION/usr/share/man/man8/jilo-web.8"
# install and enable apache vhost # we need a webserver, check for Apache and Nginx
if dpkg-query -W -f='${status}' apache2 2>/dev/null | grep -q "ok installed"; then WEB_SERVER=""
# install and enable apache vhost
if dpkg-query -W -f='${status}' apache2 2>/dev/null | grep -q "ok installed"; then
WEB_SERVER="apache2" WEB_SERVER="apache2"
cp "${DOC_DIR}/config.apache" /etc/apache2/sites-available/jilo-web.conf cp "${DOC_DIR}/config.apache" /etc/apache2/sites-available/jilo-web.conf
sed -i -e "s/\$DOMAIN/$DOMAIN/g" /etc/apache2/sites-available/jilo-web.conf sed -i -e "s/\$DOMAIN/$DOMAIN/g" /etc/apache2/sites-available/jilo-web.conf
@ -46,8 +48,8 @@ if dpkg-query -W -f='${status}' apache2 2>/dev/null | grep -q "ok installed"; th
a2ensite jilo-web.conf a2ensite jilo-web.conf
/etc/init.d/apache2 reload /etc/init.d/apache2 reload
# install and enable nginx vhost # install and enable nginx vhost
elif dpkg-query -W -f='${status}' nginx 2>/dev/null | grep -q "ok installed"; then elif dpkg-query -W -f='${status}' nginx 2>/dev/null | grep -q "ok installed"; then
WEB_SERVER="nginx" WEB_SERVER="nginx"
cp "${DOC_DIR}/config.nginx" /etc/nginx/sites-available/jilo-web cp "${DOC_DIR}/config.nginx" /etc/nginx/sites-available/jilo-web
sed -i -e "s/\$DOMAIN/$DOMAIN/g" /etc/nginx/sites-available/jilo-web sed -i -e "s/\$DOMAIN/$DOMAIN/g" /etc/nginx/sites-available/jilo-web
@ -55,13 +57,46 @@ elif dpkg-query -W -f='${status}' nginx 2>/dev/null | grep -q "ok installed"; th
sed -i -e "s%\$INSTALL_DIR%$INSTALL_DIR%g" /etc/nginx/sites-available/jilo-web sed -i -e "s%\$INSTALL_DIR%$INSTALL_DIR%g" /etc/nginx/sites-available/jilo-web
ln -s /etc/nginx/sites-available/jilo-web /etc/nginx/sites-enabled/ ln -s /etc/nginx/sites-available/jilo-web /etc/nginx/sites-enabled/
/etc/init.d/nginx reload /etc/init.d/nginx reload
else else
echo "Nginx or Apache is needed, please install one of them first." echo "Nginx or Apache is needed, please install one of them first."
exit 1 exit 1
fi
# permissions for web folder
chown -R www-data:www-data "$INSTALL_DIR"
chmod -R ug+rw "$INSTALL_DIR"
echo 'Install finished.'
}
help="Usage:
$0 [OPTION]
Options:
--install|-i - install Jilo-Web
--help|-h - show this help message
--version|-v - show version"
version="Jilo-Web deployment script
version $VERSION"
if [[ $1 ]]; then
case $1 in
-i | --install)
;;
-h | --help)
echo -e "$help"
exit 0
;;
-v | --version)
echo -e "$version"
exit 0
;;
*)
echo "Invalid option: $1" >&2
echo -e "$help"
exit 1
;;
esac
fi fi
# permissions for web folder
chown -R www-data:www-data "$INSTALL_DIR"
chmod -R ug+rw "$INSTALL_DIR"
echo 'Install finished.'