1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ethercalc_ynh.git synced 2024-09-03 18:26:36 +02:00
ethercalc_ynh/scripts/install
2014-08-26 00:49:46 +02:00

51 lines
1.2 KiB
Bash

#!/bin/bash
app="ethercalc"
# Retrieve arguments
domain=$1
path=$2
is_public=$3
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then
exit 1
fi
# Save specific settings
sudo yunohost app setting $app is_public -v $is_public
# Remove trailing "/" for next commands
path=${path%/}
# Install dependances
sudo apt-get install nodejs-legacy npm redis-server -y
sudo npm i -g ethercalc
# Copy files to the right place
sudo cp ../conf/$app /etc/init.d/
sudo chmod +x /etc/init.d/$app
sudo update-rc.d $app defaults
sudo mkdir /var/log/$app/
sudo touch /var/log/$app/$app.log
sudo chown www-data /var/log/$app/$app.log
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf*
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf*
if [ "$path" = "" ];
then
sudo cp ../conf/nginx.conf-nosub /etc/nginx/conf.d/$domain.d/$app.conf
else
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
fi
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
if [ "$is_public" = "Yes" ];
then
sudo yunohost app setting $app skipped_uris -v "/"
fi
sudo yunohost app ssowatconf
sudo service $app start