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
J. Fernando Lagrange 72846cc2a2 Fix install command
2017-09-17 19:50:54 +02:00

50 lines
1.3 KiB
Bash

#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
# Compute parameters
install_path=/home/yunohost.app/$app
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Check domain/path availability
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path}"
# Check system user availability
if ynh_system_user_exists "$app" ; then
ynh_die "System user $app already exists !"
else
ynh_system_user_create "$app" "$install_path"
fi
# Install dependencies
apt-get update
apt-get install nodejs-legacy npm python-pip python-dev python-lxml python-imaging -y -qq
pip install weboob
# Install Kresus
sudo -u $app sh -c 'cd $final_path && prefix=$final_path npm install kresus'
# Modify Nginx configuration file and copy it to Nginx conf directory
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
# Setup service
systemd_service=../conf/kresus.service
sed -i "s@YNH_HOME@$install_path@g" $systemd_service
sudo cp $systemd_service /etc/systemd/system/$app.service
systemctl enable $app
systemctl start $app
# Reload services
sudo service nginx reload