2014-08-26 00:49:46 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-09-08 00:23:35 +02:00
|
|
|
app_id_forked="ethercalc"
|
|
|
|
app_id="ether"
|
|
|
|
app_id+="calc"
|
|
|
|
instance_number=$(echo $app_id_forked | sed 's/[^0-9]//g')
|
2014-08-26 00:49:46 +02:00
|
|
|
# Retrieve arguments
|
|
|
|
domain=$1
|
|
|
|
path=$2
|
|
|
|
is_public=$3
|
2014-09-08 00:23:35 +02:00
|
|
|
port=$((instance_number+8000))
|
2014-08-26 00:49:46 +02:00
|
|
|
|
|
|
|
# Check domain/path availability
|
2014-09-08 00:23:35 +02:00
|
|
|
sudo yunohost app checkurl $domain$path -a $app_id_forked
|
2014-08-26 00:49:46 +02:00
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Save specific settings
|
2014-09-08 00:23:35 +02:00
|
|
|
sudo yunohost app setting $app_id_forked is_public -v $is_public
|
2014-08-26 00:49:46 +02:00
|
|
|
|
|
|
|
# Remove trailing "/" for next commands
|
|
|
|
path=${path%/}
|
|
|
|
|
|
|
|
# Install dependances
|
|
|
|
sudo apt-get install nodejs-legacy npm redis-server -y
|
2014-09-08 00:27:40 +02:00
|
|
|
sudo npm i -g $app_id
|
2014-08-26 00:49:46 +02:00
|
|
|
|
|
|
|
# Copy files to the right place
|
2014-09-08 00:23:35 +02:00
|
|
|
sed -i "s@YUNOPORT@$port@g" ../conf/$app_id
|
|
|
|
sed -i "s@YUNOLOG@$app_id_forked@g" ../conf/$app_id
|
|
|
|
sed -i "s@YUNOPATH@$path@g" ../conf/$app_id
|
|
|
|
sudo cp ../conf/$app_id /etc/init.d/$app_id_forked
|
|
|
|
sudo chmod +x /etc/init.d/$app_id_forked
|
|
|
|
sudo update-rc.d $app_id_forked defaults
|
|
|
|
if [ ! -d "/var/log/$app_id/" ]; then
|
|
|
|
sudo mkdir /var/log/$app_id/
|
|
|
|
fi
|
|
|
|
sudo touch /var/log/$app_id/$app_id_forked.log
|
|
|
|
sudo chown www-data /var/log/$app_id/$app_id_forked.log
|
2014-08-26 00:49:46 +02:00
|
|
|
|
|
|
|
# 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*
|
2014-09-08 00:23:35 +02:00
|
|
|
sed -i "s@YUNOPORT@$port@g" ../conf/nginx.conf*
|
2014-08-26 00:49:46 +02:00
|
|
|
if [ "$path" = "" ];
|
|
|
|
then
|
2014-09-08 00:23:35 +02:00
|
|
|
sudo cp ../conf/nginx.conf-nosub /etc/nginx/conf.d/$domain.d/$app_id_forked.conf
|
2014-08-26 00:49:46 +02:00
|
|
|
else
|
2014-09-08 00:23:35 +02:00
|
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app_id_forked.conf
|
2014-08-26 00:49:46 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
|
|
sudo service nginx reload
|
|
|
|
if [ "$is_public" = "Yes" ];
|
|
|
|
then
|
2014-09-08 00:23:35 +02:00
|
|
|
sudo yunohost app setting ethercalc skipped_regex -v "$final_path/.*"
|
2014-08-26 00:49:46 +02:00
|
|
|
fi
|
2014-09-08 00:23:35 +02:00
|
|
|
sudo service $app_id_forked stop
|
|
|
|
sudo service $app_id_forked start
|
2014-08-26 00:49:46 +02:00
|
|
|
sudo yunohost app ssowatconf
|