1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/headphones_ynh.git synced 2024-09-03 19:26:02 +02:00

📦 rewrite

This commit is contained in:
Snipees 2015-09-05 17:52:58 +02:00
parent 60926e6553
commit df7c4a3536
10 changed files with 413 additions and 110 deletions

View file

@ -16,9 +16,8 @@ Otherwise the script sets a reverse-proxy to a remote instance.
- Use **Install software** option from Yunohost admin panel
- Find textbox tagged as **Install custom App from github**
- Copy and paste: https://github.com/Snipees/headphones_ynh
- Choose an host for the instance, keep ***127.0.0.1*** to make a local installation
- Choose the listening port, local installation will use this port but will not be reachable
- Choose a fork as sources for local installation
- Choose the method installation: *local* or *remote* (as described above)
- Answer the required questions to the selected method
### More information about:

209
conf/headphones.init Normal file
View file

@ -0,0 +1,209 @@
#!/bin/sh
#
## Don't edit this file
## Edit user configuation in /etc/default/headphones to change
##
## Make sure init script is executable
## sudo chmod +x /path/to/init.ubuntu
##
## Install the init script
## sudo ln -s /path/to/init.ubuntu /etc/init.d/headphones
##
## Create the headphones daemon user:
## sudo adduser --system --no-create-home headphones
##
## Make sure /opt/headphones is owned by the headphones user
## sudo chown headphones:nogroup -R /opt/headphones
##
## Touch the default file to stop the warning message when starting
## sudo touch /etc/default/headphones
##
## To start Headphones automatically
## sudo update-rc.d headphones defaults
##
## To start/stop/restart Headphones
## sudo service headphones start
## sudo service headphones stop
## sudo service headphones restart
##
## HP_USER= #$RUN_AS, username to run headphones under, the default is headphones
## HP_HOME= #$APP_PATH, the location of Headphones.py, the default is /opt/headphones
## HP_DATA= #$DATA_DIR, the location of headphones.db, cache, logs, the default is /opt/headphones
## HP_PIDFILE= #$PID_FILE, the location of headphones.pid, the default is /var/run/headphones/headphones.pid
## PYTHON_BIN= #$DAEMON, the location of the python binary, the default is /usr/bin/python
## HP_OPTS= #$EXTRA_DAEMON_OPTS, extra cli option for headphones, i.e. " --config=/home/headphones/config.ini"
## SSD_OPTS= #$EXTRA_SSD_OPTS, extra start-stop-daemon option like " --group=users"
## HP_PORT= #$PORT_OPTS, hardcoded port for the webserver, overrides value in config.ini
##
## EXAMPLE if want to run as different user
## add HP_USER=username to /etc/default/headphones
## otherwise default headphones is used
#
### BEGIN INIT INFO
# Provides: headphones
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Should-Start: $NetworkManager
# Should-Stop: $NetworkManager
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts instance of Headphones
# Description: starts instance of Headphones using start-stop-daemon
### END INIT INFO
# Script name
NAME=headphones
# App name
DESC=Headphones
SETTINGS_LOADED=FALSE
. /lib/lsb/init-functions
# Source Headphones configuration
if [ -f /etc/default/headphones ]; then
SETTINGS=/etc/default/headphones
else
log_warning_msg "/etc/default/headphones not found using default settings.";
fi
check_retval() {
if [ $? -eq 0 ]; then
log_end_msg 0
return 0
else
log_end_msg 1
exit 1
fi
}
load_settings() {
if [ $SETTINGS_LOADED != "TRUE" ]; then
. $SETTINGS
## The defaults
# Run as username
RUN_AS=${HP_USER-headphones}
# Path to app HP_HOME=path_to_app_Headphones.py
APP_PATH=${HP_HOME-/opt/headphones}
# Data directory where headphones.db, cache and logs are stored
DATA_DIR=${HP_DATA-/opt/headphones}
# Path to store PID file
PID_FILE=${HP_PIDFILE-/var/run/headphones/headphones.pid}
# Path to python bin
DAEMON=${PYTHON_BIN-/usr/bin/python}
# Extra daemon option like: HP_OPTS=" --config=/home/headphones/config.ini"
EXTRA_DAEMON_OPTS=${HP_OPTS-}
# Extra start-stop-daemon option like START_OPTS=" --group=users"
EXTRA_SSD_OPTS=${SSD_OPTS-}
# Hardcoded port to run on, overrides config.ini settings
[ -n "$HP_PORT" ] && {
PORT_OPTS=" --port=${HP_PORT} "
}
DAEMON_OPTS=" Headphones.py --quiet --daemon --nolaunch --pidfile=${PID_FILE} --datadir=${DATA_DIR} ${PORT_OPTS}${EXTRA_DAEMON_OPTS}"
SETTINGS_LOADED=TRUE
fi
[ -x $DAEMON ] || {
log_warning_msg "$DESC: Can't execute daemon, aborting. See $DAEMON";
return 1;}
return 0
}
load_settings || exit 0
is_running () {
# returns 1 when running, else 0.
if [ -e $PID_FILE ]; then
PID=`cat $PID_FILE`
RET=$?
[ $RET -gt 1 ] && exit 1 || return $RET
else
return 1
fi
}
handle_pid () {
PID_PATH=`dirname $PID_FILE`
[ -d $PID_PATH ] || mkdir -p $PID_PATH && chown -R $RUN_AS $PID_PATH > /dev/null || {
log_warning_msg "$DESC: Could not create $PID_FILE, See $SETTINGS, aborting.";
return 1;}
if [ -e $PID_FILE ]; then
PID=`cat $PID_FILE`
if ! kill -0 $PID > /dev/null 2>&1; then
log_warning_msg "Removing stale $PID_FILE"
rm $PID_FILE
fi
fi
}
handle_datadir () {
[ -d $DATA_DIR ] || mkdir -p $DATA_DIR && chown -R $RUN_AS $DATA_DIR > /dev/null || {
log_warning_msg "$DESC: Could not create $DATA_DIR, See $SETTINGS, aborting.";
return 1;}
}
handle_updates () {
chown -R $RUN_AS $APP_PATH > /dev/null || {
log_warning_msg "$DESC: $APP_PATH not writable by $RUN_AS for web-updates";
return 0; }
}
start_headphones () {
handle_pid
handle_datadir
handle_updates
if ! is_running; then
log_daemon_msg "Starting $DESC"
start-stop-daemon -o -d $APP_PATH -c $RUN_AS --start $EXTRA_SSD_OPTS --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS
check_retval
else
log_success_msg "$DESC: already running (pid $PID)"
fi
}
stop_headphones () {
if is_running; then
log_daemon_msg "Stopping $DESC"
start-stop-daemon -o --stop --pidfile $PID_FILE --retry 15
check_retval
else
log_success_msg "$DESC: not running"
fi
}
case "$1" in
start)
start_headphones
;;
stop)
stop_headphones
;;
restart|force-reload)
stop_headphones
start_headphones
;;
status)
status_of_proc -p "$PID_FILE" "$DAEMON" "$DESC"
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac
exit 0

View file

@ -32,19 +32,28 @@
"default": "/headphones"
},
{
"name": "host",
"name": "public",
"ask": {
"en": "Is it a public application ?",
"fr": "Est-ce une application publique ?"
},
"choices": ["Yes", "No"],
"default": "No"
},
{
"name": "method",
"ask": {
"en": "Choose host for app (keep 127.0.0.1 for localhost installation)",
"fr": "Choisissez un hôte pour l'application (laissez 127.0.0.1 pour une installation locale)"
"en": "Choose installation method",
"fr": "Choisissez le type d'installation"
},
"example": "192.168.1.100",
"default": "127.0.0.1"
"choices": ["LOCAL", "REMOTE"],
"default": "LOCAL"
},
{
"name": "port",
"ask": {
"en": "Choose the listening port of the app (not used for localhost installation)",
"fr": "Choisissez le port d'écoute de l'application (non utilisé pour une installation locale)"
"en": "LOCAL: Choose the listening port of the app",
"fr": "LOCAL: Choisissez le port d'écoute de l'application"
},
"example": "8181",
"default": "8181"
@ -52,8 +61,8 @@
{
"name": "fork",
"ask": {
"en": "Source URL of GIT to use (used only for localhost installation)",
"fr": "URL du GIT source à utiliser (uniquement pour une installation locale)"
"en": "LOCAL: Source URL of GIT to use",
"fr": "LOCAL: URL du GIT source à utiliser"
},
"example": "https://github.com/Snipees/headphones",
"default": "https://github.com/rembo10/headphones"
@ -61,11 +70,31 @@
{
"name": "options",
"ask": {
"en": "Choose a downloader to configure (used only for localhost installation)",
"fr": "Choisissez un client de téléchargement (uniquement pour une installation locale)"
"en": "LOCAL: Choose a downloader to configure",
"fr": "LOCAL: Choisissez un client de téléchargement"
},
"choices": ["None", "Transmission"],
"default": "None"
},
{
"name": "host",
"ask": {
"en": "REMOTE: Specify URL for the host",
"fr": "REMOTE: Indiquez l'URL de l'hôte"
},
"example": "http://192.168.1.100:8888/myapp",
"default": "http://"
}
],
"remove": [
{
"name": "data",
"ask": {
"en": "Would you like to keep data files ?",
"fr": "Souhaitez-vous conserver les données ?"
},
"choices": ["Yes", "No"],
"default": "Yes"
}
]
}

View file

@ -1,21 +1,23 @@
#!/bin/bash
# Set variables
# Common variable declaration
app_id=headphones
app_user=headphones
app_install_dir=/opt/yunohost/$app_id
app_data_dir=/home/yunohost.app/$app_id
app_host=$(sudo yunohost app setting $app_id host)
app_domain=$(sudo yunohost app setting $app_id domain)
app_install_dir="/opt/yunohost/${app_id}"
app_data_dir="/home/yunohost.app/${app_id}"
# Retrieve arguments
app_method="$(sudo yunohost app setting ${app_id} method)"
app_domain="$(sudo yunohost app setting ${app_id} domain)"
# The parameter $1 is the backup directory location
# which will be compressed afterward
app_backup_dir=$1/apps/$app_id
mkdir -p $app_backup_dir
app_backup_dir="$1/apps/${app_id}"
sudo mkdir -p $app_backup_dir
# Backup files if localhost installation
if [[ $app_host == "127.0.0.1" ]]; then
if [[ $app_method == "LOCAL"* ]]; then
# Backup sources
sudo cp -a $app_install_dir/. $app_backup_dir/sources

View file

@ -7,21 +7,32 @@
# Retrieve arguments
app_domain=$1
app_path=$2
app_host=$3
app_port=$4
app_fork=$5
app_opts=$6
app_public=$3
app_method=$4
app_port=$5
app_fork=$6
app_opts=$7
app_host=$8
# Set variables
# Basic variable declaration
BASEDIR="$(dirname "$(pwd)")"
# Common variable declaration
app_id=headphones
app_user=headphones
app_install_dir=/opt/yunohost/$app_id
app_data_dir=/home/yunohost.app/$app_id
app_logs_dir=/var/log/$app_id
app_pid_file=/var/run/$app_id/$app_id.pid
app_config_file=$app_data_dir/config.ini
app_init_file=$app_install_dir/init-scripts/init.ubuntu
app_python_bin=/usr/bin/python
app_local_host="127.0.0.1"
app_python_bin="/usr/bin/python"
## Destinations definitions
app_install_dir="/opt/yunohost/${app_id}"
app_data_dir="/home/yunohost.app/${app_id}"
app_logs_dir="/var/log/${app_id}"
app_config_file="${app_data_dir}/config.ini"
app_pid_file="/var/run/${app_id}/${app_id}.pid"
## Sources definitions
app_src_conf="$BASEDIR/conf/${app_id}.conf"
app_src_dfts="$BASEDIR/conf/${app_id}.defaults"
app_src_init="$BASEDIR/conf/${app_id}.init"
app_src_nginx_conf="$BASEDIR/conf/nginx.conf"
# Check domain/path availability
@ -30,22 +41,22 @@ if [[ ! $? -eq 0 ]]; then
exit 1
fi
# Check port availability
sudo yunohost app checkport $app_port
if [[ ! $? -eq 0 ]]; then
exit 1
fi
# Make install if localhost installation
if [[ $app_host == "127.0.0.1" ]]; then
if [[ $app_method == "LOCAL"* ]]; then
# Check port availability
sudo yunohost app checkport $app_port
if [[ ! $? -eq 0 ]]; then
exit 1
fi
# Make directories
sudo mkdir -p $app_logs_dir
sudo mkdir -p $app_data_dir
sudo mkdir -p $app_install_dir
# Install the latest version of App using the fork
# Install latest version of app using the fork
sudo apt-get install -y git-core
sudo git clone $app_fork $app_install_dir
@ -57,26 +68,26 @@ if [[ $app_host == "127.0.0.1" ]]; then
sudo bash -c "source $app_install_dir/bin/activate && pip install cheetah"
fi
# Create App user
id -u $app_user &>/dev/null || sudo useradd --home-dir $app_install_dir --shell /bin/false $app_user
# Create app user
id -u $app_user &>/dev/null || sudo useradd --home-dir $app_data_dir --shell /bin/false $app_user
# Configure daemon
sudo sed -i "s@USERTOCHANGE@$app_user@g" ../conf/$app_id
sudo sed -i "s@APPDIRTOCHANGE@$app_install_dir@g" ../conf/$app_id
sudo sed -i "s@DATADIRTOCHANGE@$app_data_dir@g" ../conf/$app_id
sudo sed -i "s@PIDFILETOCHANGE@$app_pid_file@g" ../conf/$app_id
sudo sed -i "s@PYTBINTOCHANGE@$app_python_bin@g" ../conf/$app_id
sudo sed -i "s@OPTSTOCHANGE@$app_config_file@g" ../conf/$app_id
sudo sed -i "s@PORTTOCHANGE@$app_port@g" ../conf/$app_id
sudo cp -a ../conf/$app_id /etc/default/$app_id
sudo cp -a $app_init_file /etc/init.d/$app_id
sudo sed -i "s@USERTOCHANGE@$app_user@g" $app_src_dfts
sudo sed -i "s@APPDIRTOCHANGE@$app_install_dir@g" $app_src_dfts
sudo sed -i "s@DATADIRTOCHANGE@$app_data_dir@g" $app_src_dfts
sudo sed -i "s@PIDFILETOCHANGE@$app_pid_file@g" $app_src_dfts
sudo sed -i "s@PYTBINTOCHANGE@$app_python_bin@g" $app_src_dfts
sudo sed -i "s@OPTSTOCHANGE@$app_config_file@g" $app_src_dfts
sudo sed -i "s@PORTTOCHANGE@$app_port@g" $app_src_dfts
sudo cp -a $app_src_dfts /etc/default/$app_id
sudo cp -a $app_src_init /etc/init.d/$app_id
# Configure App
sudo sed -i "s@PATHTOCHANGE@$app_path@g" ../conf/config.ini
sudo sed -i "s@PORTTOCHANGE@$app_port@g" ../conf/config.ini
sudo sed -i "s@APPDIRTOCHANGE@$app_install_dir@g" ../conf/config.ini
sudo sed -i "s@LOGSDIRTOCHANGE@$app_logs_dir@g" ../conf/config.ini
sudo cp -a ../conf/config.ini $app_config_file
# Configure app
sudo sed -i "s@PATHTOCHANGE@$app_path@g" $app_src_conf
sudo sed -i "s@PORTTOCHANGE@$app_port@g" $app_src_conf
sudo sed -i "s@APPDIRTOCHANGE@$app_install_dir@g" $app_src_conf
sudo sed -i "s@LOGSDIRTOCHANGE@$app_logs_dir@g" $app_src_conf
sudo cp -a $app_src_conf $app_config_file
# Configure specifics options
case "$app_opts" in
@ -85,14 +96,14 @@ if [[ $app_host == "127.0.0.1" ]]; then
ref_field=(download-dir rpc-bind-address rpc-port rpc-url rpc-username rpc-password)
for i in ${ref_field[*]}; do ref_value+=$(sudo sed -n -e "/$i/ s/.*\: *//p" $ref_file | sed 's/["*,]//g'); done
ref_value=($ref_value)
sudo sed -i "s@download_torrent_dir =.*@download_torrent_dir = ${ref_value[0]}@g" ../conf/config.ini
sudo sed -i "s@transmission_host =.*@transmission_host = http://${ref_value[1]}:${ref_value[2]}${ref_value[3]}@g" ../conf/config.ini
sudo sed -i "s@transmission_username =.*@transmission_username = ${ref_value[4]}@g" ../conf/config.ini
sudo sed -i "s@transmission_password =.*@transmission_password = ${ref_value[5]}@g" ../conf/config.ini
sudo sed -i "s@torrent_downloader =.*@torrent_downloader = 1@g" ../conf/config.ini
sudo sed -i "s@keep_torrent_files =.*@keep_torrent_files = 1@g" ../conf/config.ini
sudo sed -i "s@prefer_torrents =.*@prefer_torrents = 1@g" ../conf/config.ini
sudo cp -a ../conf/config.ini $app_config_file
sudo sed -i "s@download_torrent_dir =.*@download_torrent_dir = ${ref_value[0]}@g" $app_src_conf
sudo sed -i "s@transmission_host =.*@transmission_host = http://${ref_value[1]}:${ref_value[2]}${ref_value[3]}@g" $app_src_conf
sudo sed -i "s@transmission_username =.*@transmission_username = ${ref_value[4]}@g" $app_src_conf
sudo sed -i "s@transmission_password =.*@transmission_password = ${ref_value[5]}@g" $app_src_conf
sudo sed -i "s@torrent_downloader =.*@torrent_downloader = 1@g" $app_src_conf
sudo sed -i "s@keep_torrent_files =.*@keep_torrent_files = 1@g" $app_src_conf
sudo sed -i "s@prefer_torrents =.*@prefer_torrents = 1@g" $app_src_conf
sudo cp -a $app_src_conf $app_config_file
;;
esac
@ -106,13 +117,16 @@ if [[ $app_host == "127.0.0.1" ]]; then
sudo chmod +x -R $app_logs_dir
# Add service to YunoHost's monitoring
sudo yunohost service add $app_id --log $app_logs_dir/ --status "ps aux | grep $app_id | grep -v grep"
sudo yunohost service add $app_id --log $app_logs_dir --status "ps aux | grep $app_id | grep -v grep"
# Start daemon at boot
sudo update-rc.d $app_id defaults
# Reload daemon
sudo service $app_id restart
# Start service
sudo service $app_id start
# Set proxy host variable
app_host="http://${app_local_host}:${app_port}${app_path%/}"
fi
@ -121,15 +135,21 @@ fi
app_path=${app_path%/}
# Configure Nginx
sudo sed -i "s@IPTOCHANGE@$app_host@g" ../conf/nginx.conf
sudo sed -i "s@PORTTOCHANGE@$app_port@g" ../conf/nginx.conf
sudo sed -i "s@PATHTOCHANGE@$app_path@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$app_domain.d/$app_id.conf
sudo sed -i "s@PATHTOCHANGE@$app_path@g" $app_src_nginx_conf
sudo sed -i "s@HOSTTOCHANGE@$app_host@g" $app_src_nginx_conf
sudo cp $app_src_nginx_conf /etc/nginx/conf.d/$app_domain.d/$app_id.conf
# If app is public, add url to SSOWat conf as skipped_uris
if [[ $app_public == "Yes" ]]; then
# unprotected_uris allows SSO credentials to be passed anyway.
sudo yunohost app setting $app_id unprotected_uris -v "/"
fi
# Store used IP for upgrades
sudo yunohost app setting $app_id host -v $app_host
# Save app settings
sudo yunohost app setting $app_id public -v "$app_public"
sudo yunohost app setting $app_id method -v "$app_method"
sudo yunohost app setting $app_id host -v "$app_host"
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
echo $?
sudo yunohost app ssowatconf

View file

@ -1,32 +1,41 @@
#!/bin/bash
# Set variables
# Common variable declaration
app_id=headphones
app_user=headphones
app_install_dir=/opt/yunohost/$app_id
app_data_dir=/home/yunohost.app/$app_id
app_logs_dir=/var/log/$app_id
app_host=$(sudo yunohost app setting $app_id host)
app_domain=$(sudo yunohost app setting $app_id domain)
app_install_dir="/opt/yunohost/${app_id}"
app_data_dir="/home/yunohost.app/${app_id}"
app_logs_dir="/var/log/${app_id}"
# Retrieve arguments
app_method="$(sudo yunohost app setting ${app_id} method)"
app_domain="$(sudo yunohost app setting ${app_id} domain)"
keep_data=$1
# Remove files if localhost installation
if [[ $app_host == "127.0.0.1" ]]; then
if [[ $app_method == "LOCAL"* ]]; then
# Kill App and remove from boot
# Kill app and remove from boot
sudo service $app_id stop
sudo killall $app_id
sudo update-rc.d $app_id remove
# Delete App user
# Delete app user
sudo deluser $app_user
# Remove sources
sudo rm -rf $app_install_dir
# Remove logs
if [[ $app_logs_dir != "$app_data_dir"* ]]; then
sudo rm -rf $app_logs_dir
fi
# Remove data
sudo rm -rf $app_data_dir
sudo rm -rf $app_logs_dir
if [[ $keep_data == "No" ]]; then
sudo rm -rf $app_data_dir
fi
# Remove daemon config
sudo rm -f /etc/init.d/$app_id
@ -39,6 +48,9 @@ fi
# Remove Nginx parameters
sudo rm -f /etc/nginx/conf.d/$app_domain.d/$app_id.conf
# Remove Yunohost service
sudo yunohost service remove $app_id
# Reload Nginx and update Yunohost
sudo service nginx reload
sudo yunohost service remove $app_id
sudo yunohost app ssowatconf

View file

@ -1,21 +1,23 @@
#!/bin/bash
# Set variables
# Common variable declaration
app_id=headphones
app_user=headphones
app_install_dir=/opt/yunohost/$app_id
app_data_dir=/home/yunohost.app/$app_id
app_host=$(sudo yunohost app setting $app_id host)
app_domain=$(sudo yunohost app setting $app_id domain)
app_install_dir="/opt/yunohost/${app_id}"
app_data_dir="/home/yunohost.app/${app_id}"
# Retrieve arguments
app_method="$(sudo yunohost app setting ${app_id} method)"
app_domain="$(sudo yunohost app setting ${app_id} domain)"
# The parameter $1 is the uncompressed restore directory location
app_backup_dir=$1/apps/$app_id
app_backup_dir="$1/apps/${app_id}"
# Restore files if localhost installation
if [[ $app_host == "127.0.0.1" ]]; then
if [[ $app_method == "LOCAL"* ]]; then
# Kill App
# Kill app
sudo service $app_id stop
sudo killall $app_id
@ -51,5 +53,4 @@ sudo cp -a $app_backup_dir/nginx.conf /etc/nginx/conf.d/$app_domain.d/$app_id.co
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
echo $?
sudo yunohost app ssowatconf

View file

@ -1,39 +1,70 @@
#!/bin/bash
# Set variables
# Basic variable declaration
BASEDIR="$(dirname "$(pwd)")"
# Common variable declaration
app_id=headphones
app_user=headphones
app_install_dir=/opt/yunohost/$app_id
app_init_file=$app_install_dir/init-scripts/init.ubuntu
app_host=$(sudo yunohost app setting $app_id host)
app_install_dir="/opt/yunohost/${app_id}"
app_data_dir="/home/yunohost.app/${app_id}"
app_logs_dir="/var/log/${app_id}"
## Sources definitions
app_src_init="$BASEDIR/conf/${app_id}.init"
app_src_nginx_conf="$BASEDIR/conf/nginx.conf"
# Retrieve arguments
app_public="$(sudo yunohost app setting ${app_id} public)"
app_method="$(sudo yunohost app setting ${app_id} method)"
app_domain="$(sudo yunohost app setting ${app_id} domain)"
app_path="$(sudo yunohost app setting ${app_id} path)"
app_host="$(sudo yunohost app setting ${app_id} host)"
# Make upgrade if localhost installation
if [[ $app_host == "127.0.0.1" ]]; then
if [[ $app_method == "LOCAL"* ]]; then
# Kill App
# Kill app
sudo service $app_id stop
sudo killall $app_id
# Upgrade to the latest version of App using the fork
# Upgrade to the latest version of app using the fork
cd $app_install_dir && sudo git pull
cd -
# Upgrade dependencies
# Update init file
sudo cp -a $app_init_file /etc/init.d/$app_id
sudo cp -a $app_src_init /etc/init.d/$app_id
# Set rights
sudo chown -R $app_user $app_install_dir
sudo chmod +x /etc/init.d/$app_id
sudo chmod +x -R $app_install_dir
# Reload daemon
sudo service $app_id restart
# Start service
sudo service $app_id start
fi
# Reload Nginx
sudo service nginx reload
# Remove trailing "/" for next commands
app_path=${app_path%/}
# Configure Nginx
sudo sed -i "s@PATHTOCHANGE@$app_path@g" $app_src_nginx_conf
sudo sed -i "s@HOSTTOCHANGE@$app_host@g" $app_src_nginx_conf
sudo cp $app_src_nginx_conf /etc/nginx/conf.d/$app_domain.d/$app_id.conf
# If app is public, add url to SSOWat conf as skipped_uris
if [[ $app_public = "Yes" ]];
then
# See install script
sudo yunohost app setting $app_id unprotected_uris -v "/"
# Remove old settings
sudo yunohost app setting $app_id skipped_uris -d
fi
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app ssowatconf