1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/kresus_ynh.git synced 2024-09-03 19:36:10 +02:00
kresus_ynh/scripts/install

51 lines
1.3 KiB
Text
Raw Normal View History

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
# Retrieve arguments
2017-09-17 11:03:01 +02:00
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
2016-09-09 11:07:28 +02:00
# Compute parameters
2017-09-17 11:58:51 +02:00
install_path=/home/yunohost.app/$app
2016-09-09 11:07:28 +02:00
# Source YunoHost helpers
2017-09-17 11:03:01 +02:00
source /usr/share/yunohost/helpers
2016-09-09 11:07:28 +02:00
# Check domain/path availability
2017-09-17 11:03:01 +02:00
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path}"
2016-09-09 11:07:28 +02:00
# Check system user availability
if ynh_system_user_exists "$app" ; then
ynh_die "System user $app already exists !"
else
2017-09-17 11:58:51 +02:00
ynh_system_user_create "$app" "$install_path"
fi
2016-09-09 11:07:28 +02:00
# Install dependencies
2017-09-17 11:58:51 +02:00
apt-get update
apt-get install nodejs-legacy npm python-pip python-dev python-lxml python-imaging -y -qq
pip install weboob
2017-09-17 11:58:51 +02:00
# Install Kresus
2017-09-17 12:18:12 +02:00
sudo -u $app sh -c "nmp install kresus"
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
2017-09-17 11:58:51 +02:00
sed -i "s@YNH_HOME@$install_path@g" $systemd_service
2017-09-17 11:03:01 +02:00
sudo cp $systemd_service /etc/systemd/system/$app.service
systemctl enable $app
systemctl start $app
2016-09-09 11:07:28 +02:00
# Reload services
2017-09-17 11:03:01 +02:00
sudo service nginx reload