mirror of
https://github.com/YunoHost-Apps/couchpotato_ynh.git
synced 2024-09-03 18:16:22 +02:00
📦 rewrite
This commit is contained in:
parent
ffa132d016
commit
6e87199031
10 changed files with 335 additions and 110 deletions
|
@ -10,6 +10,6 @@ CP_HOME=APPDIRTOCHANGE #$APP_PATH, the location of couchpotato.py, the defau
|
||||||
CP_DATA=DATADIRTOCHANGE #$DATA_DIR, the location of couchpotato.db, cache, logs, the default is /opt/couchpotato
|
CP_DATA=DATADIRTOCHANGE #$DATA_DIR, the location of couchpotato.db, cache, logs, the default is /opt/couchpotato
|
||||||
CP_PIDFILE=PIDFILETOCHANGE #$PID_FILE, the location of couchpotato.pid, the default is /var/run/couchpotato/couchpotato.pid
|
CP_PIDFILE=PIDFILETOCHANGE #$PID_FILE, the location of couchpotato.pid, the default is /var/run/couchpotato/couchpotato.pid
|
||||||
PYTHON_BIN=PYTBINTOCHANGE #$DAEMON, the location of the python binary, the default is /usr/bin/python
|
PYTHON_BIN=PYTBINTOCHANGE #$DAEMON, the location of the python binary, the default is /usr/bin/python
|
||||||
CP_OPTS=" --config=OPTSTOCHANGE" #$EXTRA_DAEMON_OPTS, extra cli option for couchpotato, i.e. " --config_file=/home/couchpotato/couchpotato.ini"
|
CP_OPTS=" --config_file=OPTSTOCHANGE" #$EXTRA_DAEMON_OPTS, extra cli option for couchpotato, i.e. " --config_file=/home/couchpotato/couchpotato.ini"
|
||||||
#SSD_OPTS=SSDTOCHANGE #$EXTRA_SSD_OPTS, extra start-stop-daemon option like " --group=users"
|
#SSD_OPTS=SSDTOCHANGE #$EXTRA_SSD_OPTS, extra start-stop-daemon option like " --group=users"
|
||||||
#CP_PORT=PORTTOCHANGE #$PORT_OPTS, hardcoded port for the webserver, overrides value in couchpotato.ini
|
#CP_PORT=PORTTOCHANGE #$PORT_OPTS, hardcoded port for the webserver, overrides value in couchpotato.ini
|
135
conf/couchpotato.init
Normal file
135
conf/couchpotato.init
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: couchpotato
|
||||||
|
# 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 CouchPotato
|
||||||
|
# Description: starts instance of CouchPotato using start-stop-daemon
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
|
# Check for existance of defaults file
|
||||||
|
# and utilze if available
|
||||||
|
if [ -f /etc/default/couchpotato ]; then
|
||||||
|
. /etc/default/couchpotato
|
||||||
|
else
|
||||||
|
echo "/etc/default/couchpotato not found using default settings.";
|
||||||
|
fi
|
||||||
|
|
||||||
|
. /lib/lsb/init-functions
|
||||||
|
|
||||||
|
# Script name
|
||||||
|
NAME=couchpotato
|
||||||
|
|
||||||
|
# App name
|
||||||
|
DESC=CouchPotato
|
||||||
|
|
||||||
|
## Don't edit this file
|
||||||
|
## Edit user configuation in /etc/default/couchpotato to change
|
||||||
|
##
|
||||||
|
## CP_USER= #$RUN_AS, username to run couchpotato under, the default is couchpotato
|
||||||
|
## CP_HOME= #$APP_PATH, the location of couchpotato.py, the default is /opt/couchpotato
|
||||||
|
## CP_DATA= #$DATA_DIR, the location of couchpotato.db, cache, logs, the default is /var/opt/couchpotato
|
||||||
|
## CP_PIDFILE= #$PID_FILE, the location of couchpotato.pid, the default is /var/run/couchpotato/couchpotato.pid
|
||||||
|
## PYTHON_BIN= #$DAEMON, the location of the python binary, the default is /usr/bin/python
|
||||||
|
## CP_OPTS= #$EXTRA_DAEMON_OPTS, extra cli option for couchpotato, i.e. " --config_file=/home/couchpotato/couchpotato.ini"
|
||||||
|
## SSD_OPTS= #$EXTRA_SSD_OPTS, extra start-stop-daemon option like " --group=users"
|
||||||
|
##
|
||||||
|
## EXAMPLE if want to run as different user
|
||||||
|
## add CP_USER=username to /etc/default/couchpotato
|
||||||
|
## otherwise default couchpotato is used
|
||||||
|
|
||||||
|
# Run CP as username
|
||||||
|
RUN_AS=${CP_USER-couchpotato}
|
||||||
|
|
||||||
|
# Path to app
|
||||||
|
# CP_HOME=path_to_app_CouchPotato.py
|
||||||
|
APP_PATH=${CP_HOME-/opt/couchpotato/}
|
||||||
|
|
||||||
|
# Data directory where couchpotato.db, cache and logs are stored
|
||||||
|
DATA_DIR=${CP_DATA-/var/opt/couchpotato}
|
||||||
|
|
||||||
|
# Path to store PID file
|
||||||
|
PID_FILE=${CP_PIDFILE-/var/run/couchpotato/couchpotato.pid}
|
||||||
|
|
||||||
|
# path to python bin
|
||||||
|
DAEMON=${PYTHON_BIN-/usr/bin/python}
|
||||||
|
|
||||||
|
# Extra daemon option like: CP_OPTS=" --config=/home/couchpotato/couchpotato.ini"
|
||||||
|
EXTRA_DAEMON_OPTS=${CP_OPTS-}
|
||||||
|
|
||||||
|
# Extra start-stop-daemon option like START_OPTS=" --group=users"
|
||||||
|
EXTRA_SSD_OPTS=${SSD_OPTS-}
|
||||||
|
|
||||||
|
|
||||||
|
## Parameter | Description
|
||||||
|
## ————————————— | ————————————————————————————————————
|
||||||
|
## data_dir | Absolute or ~/ path of the data dir
|
||||||
|
## config_file | Absolute or ~/ path of the settings file (default DATA_DIR/settings.conf)
|
||||||
|
## debug | Debug mode
|
||||||
|
## console_log | Log to console
|
||||||
|
## quiet | No console logging
|
||||||
|
## daemon | Daemonize the app
|
||||||
|
## pid_file | Path to pidfile needed for daemon
|
||||||
|
|
||||||
|
|
||||||
|
PID_PATH=`dirname $PID_FILE`
|
||||||
|
DAEMON_OPTS="CouchPotato.py --quiet --daemon --pid_file=${PID_FILE} --data_dir=${DATA_DIR} ${EXTRA_DAEMON_OPTS}"
|
||||||
|
|
||||||
|
|
||||||
|
test -x $DAEMON || exit 0
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Create PID directory if not exist and ensure the CouchPotato user can write to it
|
||||||
|
if [ ! -d $PID_PATH ]; then
|
||||||
|
mkdir -p $PID_PATH
|
||||||
|
chown $RUN_AS $PID_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d $DATA_DIR ]; then
|
||||||
|
mkdir -p $DATA_DIR
|
||||||
|
chown $RUN_AS $DATA_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e $PID_FILE ]; then
|
||||||
|
PID=`cat $PID_FILE`
|
||||||
|
if ! kill -0 $PID > /dev/null 2>&1; then
|
||||||
|
echo "Removing stale $PID_FILE"
|
||||||
|
rm $PID_FILE
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
touch $PID_FILE
|
||||||
|
chown $RUN_AS $PID_FILE
|
||||||
|
echo "Starting $DESC"
|
||||||
|
start-stop-daemon -d $APP_PATH -c $RUN_AS $EXTRA_SSD_OPTS --start --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
echo "Stopping $DESC"
|
||||||
|
start-stop-daemon --stop --pidfile $PID_FILE --retry 15 --oknodo
|
||||||
|
;;
|
||||||
|
|
||||||
|
restart|force-reload)
|
||||||
|
echo "Restarting $DESC"
|
||||||
|
start-stop-daemon --stop --pidfile $PID_FILE --retry 15 --oknodo
|
||||||
|
start-stop-daemon -d $APP_PATH -c $RUN_AS $EXTRA_SSD_OPTS --start --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS
|
||||||
|
;;
|
||||||
|
|
||||||
|
status)
|
||||||
|
status_of_proc -p $PID_FILE "$DAEMON" "$NAME"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
N=/etc/init.d/$NAME
|
||||||
|
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
|
@ -1,7 +1,7 @@
|
||||||
location PATHTOCHANGE {
|
location PATHTOCHANGE {
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_pass_header Server;
|
proxy_pass_header Server;
|
||||||
proxy_pass http://IPTOCHANGE:PORTTOCHANGEPATHTOCHANGE;
|
proxy_pass HOSTTOCHANGE;
|
||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
proxy_set_header Host $http_host;
|
proxy_set_header Host $http_host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
|
|
@ -32,19 +32,28 @@
|
||||||
"default": "/couchpotato"
|
"default": "/couchpotato"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"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": {
|
"ask": {
|
||||||
"en": "Choose host for app (keep 127.0.0.1 for localhost installation)",
|
"en": "Choose installation method",
|
||||||
"fr": "Choisissez un hôte pour l'application (laissez 127.0.0.1 pour une installation locale)"
|
"fr": "Choisissez le type d'installation"
|
||||||
},
|
},
|
||||||
"example": "192.168.1.100",
|
"choices": ["LOCAL", "REMOTE"],
|
||||||
"default": "127.0.0.1"
|
"default": "LOCAL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "port",
|
"name": "port",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Choose the listening port of the app (not used for localhost installation)",
|
"en": "LOCAL: Choose the listening port of the app",
|
||||||
"fr": "Choisissez le port d'écoute de l'application (non utilisé pour une installation locale)"
|
"fr": "LOCAL: Choisissez le port d'écoute de l'application"
|
||||||
},
|
},
|
||||||
"example": "5050",
|
"example": "5050",
|
||||||
"default": "5050"
|
"default": "5050"
|
||||||
|
@ -52,11 +61,31 @@
|
||||||
{
|
{
|
||||||
"name": "fork",
|
"name": "fork",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Source URL of GIT to use (used only for localhost installation)",
|
"en": "LOCAL: Source URL of GIT to use",
|
||||||
"fr": "URL du GIT source à utiliser (uniquement pour une installation locale)"
|
"fr": "LOCAL: URL du GIT source à utiliser"
|
||||||
},
|
},
|
||||||
"example": "https://github.com/Adelscott/CouchPotatoServer",
|
"example": "https://github.com/Adelscott/CouchPotatoServer",
|
||||||
"default": "https://github.com/RuudBurger/CouchPotatoServer"
|
"default": "https://github.com/RuudBurger/CouchPotatoServer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,23 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Set variables
|
# Common variable declaration
|
||||||
app_id=couchpotato
|
app_id=couchpotato
|
||||||
app_user=couchpotato
|
app_user=couchpotato
|
||||||
app_install_dir=/opt/yunohost/$app_id
|
app_install_dir="/opt/yunohost/${app_id}"
|
||||||
app_data_dir=/home/yunohost.app/$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)
|
# 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
|
# The parameter $1 is the backup directory location
|
||||||
# which will be compressed afterward
|
# which will be compressed afterward
|
||||||
app_backup_dir=$1/apps/$app_id
|
app_backup_dir="$1/apps/${app_id}"
|
||||||
mkdir -p $app_backup_dir
|
sudo mkdir -p $app_backup_dir
|
||||||
|
|
||||||
|
|
||||||
# Backup files if localhost installation
|
# Backup files if localhost installation
|
||||||
if [[ $app_host == "127.0.0.1" ]]; then
|
if [[ $app_method == "LOCAL"* ]]; then
|
||||||
|
|
||||||
# Backup sources
|
# Backup sources
|
||||||
sudo cp -a $app_install_dir/. $app_backup_dir/sources
|
sudo cp -a $app_install_dir/. $app_backup_dir/sources
|
||||||
|
|
126
scripts/install
126
scripts/install
|
@ -7,21 +7,31 @@
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
app_domain=$1
|
app_domain=$1
|
||||||
app_path=$2
|
app_path=$2
|
||||||
app_host=$3
|
app_public=$3
|
||||||
app_port=$4
|
app_method=$4
|
||||||
app_fork=$5
|
app_port=$5
|
||||||
#app_opts=$6
|
app_fork=$6
|
||||||
|
app_host=$7
|
||||||
|
|
||||||
# Set variables
|
# Basic variable declaration
|
||||||
|
BASEDIR="$(dirname "$(pwd)")"
|
||||||
|
|
||||||
|
# Common variable declaration
|
||||||
app_id=couchpotato
|
app_id=couchpotato
|
||||||
app_user=couchpotato
|
app_user=couchpotato
|
||||||
app_install_dir=/opt/yunohost/$app_id
|
app_local_host="127.0.0.1"
|
||||||
app_data_dir=/home/yunohost.app/$app_id
|
app_python_bin="/usr/bin/python"
|
||||||
app_logs_dir=$app_data_dir/logs
|
## Destinations definitions
|
||||||
app_pid_file=/var/run/$app_id/$app_id.pid
|
app_install_dir="/opt/yunohost/${app_id}"
|
||||||
app_config_file=$app_data_dir/config.ini
|
app_data_dir="/home/yunohost.app/${app_id}"
|
||||||
app_init_file=$app_install_dir/init/ubuntu
|
app_logs_dir="/var/log/${app_id}"
|
||||||
app_python_bin=/usr/bin/python
|
app_config_file="${app_data_dir}/settings.conf"
|
||||||
|
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
|
# Check domain/path availability
|
||||||
|
@ -30,21 +40,21 @@ if [[ ! $? -eq 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check port availability
|
|
||||||
sudo yunohost app checkport $app_port
|
|
||||||
if [[ ! $? -eq 0 ]]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Make install if localhost installation
|
# 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
|
# Make directories
|
||||||
sudo mkdir -p $app_data_dir
|
sudo mkdir -p $app_data_dir
|
||||||
sudo mkdir -p $app_install_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 apt-get install -y git-core
|
||||||
sudo git clone $app_fork $app_install_dir
|
sudo git clone $app_fork $app_install_dir
|
||||||
|
|
||||||
|
@ -56,43 +66,32 @@ if [[ $app_host == "127.0.0.1" ]]; then
|
||||||
sudo bash -c "source $app_install_dir/bin/activate && pip install cheetah"
|
sudo bash -c "source $app_install_dir/bin/activate && pip install cheetah"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create App user
|
# Create app user
|
||||||
id -u $app_user &>/dev/null || sudo useradd --home-dir $app_install_dir --shell /bin/false $app_user
|
id -u $app_user &>/dev/null || sudo useradd --home-dir $app_install_dir --shell /bin/false $app_user
|
||||||
|
|
||||||
# Configure daemon
|
# Configure daemon
|
||||||
sudo sed -i "s@USERTOCHANGE@$app_user@g" ../conf/$app_id
|
sudo sed -i "s@USERTOCHANGE@$app_user@g" $app_src_dfts
|
||||||
sudo sed -i "s@APPDIRTOCHANGE@$app_install_dir@g" ../conf/$app_id
|
sudo sed -i "s@APPDIRTOCHANGE@$app_install_dir@g" $app_src_dfts
|
||||||
sudo sed -i "s@DATADIRTOCHANGE@$app_data_dir@g" ../conf/$app_id
|
sudo sed -i "s@DATADIRTOCHANGE@$app_data_dir@g" $app_src_dfts
|
||||||
sudo sed -i "s@PIDFILETOCHANGE@$app_pid_file@g" ../conf/$app_id
|
sudo sed -i "s@PIDFILETOCHANGE@$app_pid_file@g" $app_src_dfts
|
||||||
sudo sed -i "s@PYTBINTOCHANGE@$app_python_bin@g" ../conf/$app_id
|
sudo sed -i "s@PYTBINTOCHANGE@$app_python_bin@g" $app_src_dfts
|
||||||
sudo sed -i "s@OPTSTOCHANGE@$app_config_file@g" ../conf/$app_id
|
sudo sed -i "s@OPTSTOCHANGE@$app_config_file@g" $app_src_dfts
|
||||||
sudo cp -a ../conf/$app_id /etc/default/$app_id
|
sudo cp -a $app_src_dfts /etc/default/$app_id
|
||||||
sudo cp -a $app_init_file /etc/init.d/$app_id
|
sudo cp -a $app_src_init /etc/init.d/$app_id
|
||||||
|
|
||||||
# Configure App
|
# Configure App
|
||||||
sudo sed -i "s@PATHTOCHANGE@$app_path@g" ../conf/config.ini
|
sudo sed -i "s@PATHTOCHANGE@$app_path@g" $app_src_conf
|
||||||
sudo sed -i "s@PORTTOCHANGE@$app_port@g" ../conf/config.ini
|
sudo sed -i "s@PORTTOCHANGE@$app_port@g" $app_src_conf
|
||||||
sudo sed -i "s@DATADIRTOCHANGE@$app_data_dir@g" ../conf/config.ini
|
sudo sed -i "s@DATADIRTOCHANGE@$app_data_dir@g" $app_src_conf
|
||||||
sudo cp -a ../conf/config.ini $app_config_file
|
sudo cp -a $app_src_conf $app_config_file
|
||||||
|
|
||||||
## Configure specifics options
|
# Redirect logs directory
|
||||||
#case "$app_opts" in
|
if [[ $app_logs_dir != "$app_data_dir"* ]]; then
|
||||||
#*"Transmission"*)
|
sudo mkdir -p $app_logs_dir
|
||||||
# ref_file=$(sudo sed -n -e '/^CONFIG_DIR/ s/.*\= *//p' $(find /etc/default -name '*transmission*') | sed 's/["* ]//g')/settings.json
|
sudo chown -R $app_user $app_logs_dir
|
||||||
# ref_field=(download-dir rpc-bind-address rpc-port rpc-url rpc-username rpc-password)
|
sudo chmod +x -R $app_logs_dir
|
||||||
# for i in ${ref_field[*]}; do ref_value+=$(sudo sed -n -e "/$i/ s/.*\: *//p" $ref_file | sed 's/["*,]//g'); done
|
sudo sed -i "s@self.log_dir =.*@self.log_dir = '$app_logs_dir'@g" $app_install_dir/CouchPotato.py
|
||||||
# ref_value=($ref_value)
|
fi
|
||||||
# sudo sed -i "s@torrent_download_dir =.*@torrent_download_dir = ${ref_value[0]}@g" ../conf/config.ini
|
|
||||||
# sudo sed -i "s@torrent_path =.*@torrent_path = ${ref_value[0]}@g" ../conf/config.ini
|
|
||||||
# sudo sed -i "s@torrent_host =.*@torrent_host = http://${ref_value[1]}:${ref_value[2]}${ref_value[3]}@g" ../conf/config.ini
|
|
||||||
# sudo sed -i "s@torrent_username =.*@torrent_username = ${ref_value[4]}@g" ../conf/config.ini
|
|
||||||
# sudo sed -i "s@torrent_password =.*@torrent_password = ${ref_value[5]}@g" ../conf/config.ini
|
|
||||||
# sudo sed -i "s@torrent_method =.*@torrent_method = transmission@g" ../conf/config.ini
|
|
||||||
# sudo sed -i "s@torrent_custom_url =.*@torrent_custom_url = 1@g" ../conf/config.ini
|
|
||||||
# sudo sed -i "s@use_torrents =.*@use_torrents = 1@g" ../conf/config.ini
|
|
||||||
# sudo cp -a ../conf/config.ini $app_config_file
|
|
||||||
# ;;
|
|
||||||
#esac
|
|
||||||
|
|
||||||
# Set rights
|
# Set rights
|
||||||
sudo chown -R $app_user $app_install_dir
|
sudo chown -R $app_user $app_install_dir
|
||||||
|
@ -102,7 +101,7 @@ if [[ $app_host == "127.0.0.1" ]]; then
|
||||||
sudo chmod +x -R $app_data_dir
|
sudo chmod +x -R $app_data_dir
|
||||||
|
|
||||||
# Add service to YunoHost's monitoring
|
# 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
|
# Start daemon at boot
|
||||||
sudo update-rc.d $app_id defaults
|
sudo update-rc.d $app_id defaults
|
||||||
|
@ -110,6 +109,9 @@ if [[ $app_host == "127.0.0.1" ]]; then
|
||||||
# Reload daemon
|
# Reload daemon
|
||||||
sudo service $app_id restart
|
sudo service $app_id restart
|
||||||
|
|
||||||
|
# Set proxy host variable
|
||||||
|
app_host="http://${app_local_host}:${app_port}${app_path%/}"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,15 +119,21 @@ fi
|
||||||
app_path=${app_path%/}
|
app_path=${app_path%/}
|
||||||
|
|
||||||
# Configure Nginx
|
# Configure Nginx
|
||||||
sudo sed -i "s@IPTOCHANGE@$app_host@g" ../conf/nginx.conf
|
sudo sed -i "s@PATHTOCHANGE@$app_path@g" $app_src_nginx_conf
|
||||||
sudo sed -i "s@PORTTOCHANGE@$app_port@g" ../conf/nginx.conf
|
sudo sed -i "s@HOSTTOCHANGE@$app_host@g" $app_src_nginx_conf
|
||||||
sudo sed -i "s@PATHTOCHANGE@$app_path@g" ../conf/nginx.conf
|
sudo cp $app_src_nginx_conf /etc/nginx/conf.d/$app_domain.d/$app_id.conf
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$app_domain.d/$app_id.conf
|
|
||||||
|
|
||||||
# Store used IP for upgrades
|
# If app is public, add url to SSOWat conf as skipped_uris
|
||||||
sudo yunohost app setting $app_id host -v $app_host
|
if [[ $app_public == "Yes" ]]; then
|
||||||
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||||
|
sudo yunohost app setting $app_id unprotected_uris -v "/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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
|
# Reload Nginx and regenerate SSOwat conf
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
echo $?
|
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
|
@ -1,30 +1,41 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Set variables
|
# Common variable declaration
|
||||||
app_id=couchpotato
|
app_id=couchpotato
|
||||||
app_user=couchpotato
|
app_user=couchpotato
|
||||||
app_install_dir=/opt/yunohost/$app_id
|
app_install_dir="/opt/yunohost/${app_id}"
|
||||||
app_data_dir=/home/yunohost.app/$app_id
|
app_data_dir="/home/yunohost.app/${app_id}"
|
||||||
app_host=$(sudo yunohost app setting $app_id host)
|
app_logs_dir="/var/log/${app_id}"
|
||||||
app_domain=$(sudo yunohost app setting $app_id domain)
|
|
||||||
|
# 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
|
# 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 service $app_id stop
|
||||||
sudo killall $app_id
|
sudo killall $app_id
|
||||||
sudo update-rc.d $app_id remove
|
sudo update-rc.d $app_id remove
|
||||||
|
|
||||||
# Delete App user
|
# Delete app user
|
||||||
sudo deluser $app_user
|
sudo deluser $app_user
|
||||||
|
|
||||||
# Remove sources
|
# Remove sources
|
||||||
sudo rm -rf $app_install_dir
|
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
|
# Remove data
|
||||||
sudo rm -rf $app_data_dir
|
if [[ $keep_data == "No" ]]; then
|
||||||
|
sudo rm -rf $app_data_dir
|
||||||
|
fi
|
||||||
|
|
||||||
# Remove daemon config
|
# Remove daemon config
|
||||||
sudo rm -f /etc/init.d/$app_id
|
sudo rm -f /etc/init.d/$app_id
|
||||||
|
@ -37,6 +48,9 @@ fi
|
||||||
# Remove Nginx parameters
|
# Remove Nginx parameters
|
||||||
sudo rm -f /etc/nginx/conf.d/$app_domain.d/$app_id.conf
|
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
|
# Reload Nginx and update Yunohost
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
sudo yunohost service remove $app_id
|
sudo yunohost app ssowatconf
|
|
@ -1,21 +1,23 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Set variables
|
# Common variable declaration
|
||||||
app_id=couchpotato
|
app_id=htpc-manager
|
||||||
app_user=couchpotato
|
app_user=htpc-manager
|
||||||
app_install_dir=/opt/yunohost/$app_id
|
app_install_dir="/opt/yunohost/${app_id}"
|
||||||
app_data_dir=/home/yunohost.app/$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)
|
# 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
|
# 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
|
# 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 service $app_id stop
|
||||||
sudo killall $app_id
|
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
|
# Reload Nginx and regenerate SSOwat conf
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
echo $?
|
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
|
@ -1,27 +1,46 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Set variables
|
# Basic variable declaration
|
||||||
|
BASEDIR="$(dirname "$(pwd)")"
|
||||||
|
|
||||||
|
# Common variable declaration
|
||||||
app_id=couchpotato
|
app_id=couchpotato
|
||||||
app_user=couchpotato
|
app_user=couchpotato
|
||||||
app_install_dir=/opt/yunohost/$app_id
|
app_install_dir="/opt/yunohost/${app_id}"
|
||||||
app_init_file=$app_install_dir/init/ubuntu
|
app_data_dir="/home/yunohost.app/${app_id}"
|
||||||
app_host=$(sudo yunohost app setting $app_id host)
|
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
|
# 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 service $app_id stop
|
||||||
sudo killall $app_id
|
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 $app_install_dir && sudo git pull
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
# Upgrade dependencies
|
# Upgrade dependencies
|
||||||
|
|
||||||
|
# Redirect logs directory
|
||||||
|
if [[ $app_logs_dir != $app_data_dir ]]; then
|
||||||
|
sudo sed -i "s@self.log_dir =.*@self.log_dir = '$app_logs_dir'@g" $app_install_dir/CouchPotato.py
|
||||||
|
fi
|
||||||
|
|
||||||
# Update init file
|
# 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
|
# Set rights
|
||||||
sudo chown -R $app_user $app_install_dir
|
sudo chown -R $app_user $app_install_dir
|
||||||
|
@ -29,11 +48,28 @@ if [[ $app_host == "127.0.0.1" ]]; then
|
||||||
sudo chmod +x -R $app_install_dir
|
sudo chmod +x -R $app_install_dir
|
||||||
|
|
||||||
# Reload daemon
|
# Reload daemon
|
||||||
sudo service $app_id restart
|
sudo service $app_id start
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Reload Nginx
|
# Remove trailing "/" for next commands
|
||||||
sudo service nginx reload
|
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
|
||||||
|
|
Loading…
Add table
Reference in a new issue