2016-09-09 11:07:28 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
# Source YunoHost helpers
|
2017-09-17 11:03:01 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2016-09-09 11:07:28 +02:00
|
|
|
|
|
|
|
# Retrieve app settings
|
2017-09-17 11:03:01 +02:00
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
|
|
path=$(ynh_app_setting_get "$app" path)
|
2016-09-09 11:07:28 +02:00
|
|
|
|
|
|
|
# Build the app
|
2017-09-17 11:03:01 +02:00
|
|
|
src_path=/home/yunohost.app/$app
|
|
|
|
sudo mkdir -p $src_path $src_path/node_modules
|
|
|
|
sudo git clone https://framagit.org/bnjbvr/kresus.git $src_path
|
|
|
|
sudo npm install --prefix $src_path $src_path
|
|
|
|
sudo .$src_path/scripts/build.sh
|
2016-09-09 11:07:28 +02:00
|
|
|
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
2017-09-17 11:03:01 +02:00
|
|
|
nginx_conf=../conf/nginx.conf
|
|
|
|
sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf
|
|
|
|
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
2016-09-09 11:07:28 +02:00
|
|
|
|
|
|
|
# Setup service
|
2017-09-17 11:03:01 +02:00
|
|
|
systemd_service=../conf/kresus.service
|
|
|
|
sed -i "s@APP_TO_CHANGE@$app@g" $systemd_service
|
|
|
|
sudo cp $systemd_service /etc/systemd/system/$app.service
|
|
|
|
systemctl enable $app
|
|
|
|
systemctl start $app
|
|
|
|
|
2016-09-09 11:07:28 +02:00
|
|
|
# Reload nginx service
|
2017-09-17 11:03:01 +02:00
|
|
|
sudo service nginx reload
|