mirror of
https://github.com/YunoHost-Apps/headphones_ynh.git
synced 2024-09-03 19:26:02 +02:00
Fix
This commit is contained in:
parent
8f2a891a98
commit
f82a69a65b
6 changed files with 334 additions and 298 deletions
7
conf/app.src
Normal file
7
conf/app.src
Normal file
|
@ -0,0 +1,7 @@
|
|||
SOURCE_URL=https://github.com/rembo10/headphones/archive/refs/tags/v0.6.0-beta.5.tar.gz
|
||||
SOURCE_SUM=b96c09fc7c384affa8beab0995447d54ed2d5bd4022278068e5ee93b71e07be8
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
SOURCE_EXTRACT=true
|
|
@ -1,15 +1,15 @@
|
|||
location PATHTOCHANGE {
|
||||
proxy_http_version 1.1;
|
||||
proxy_pass_header Server;
|
||||
proxy_pass HOSTTOCHANGE;
|
||||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||
location __PATH__/ {
|
||||
|
||||
proxy_pass https://127.0.0.1:__PORT__;
|
||||
proxy_redirect off;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host $server_name;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
more_clear_input_headers 'Accept-Encoding';
|
||||
}
|
||||
|
|
13
conf/systemd.service
Normal file
13
conf/systemd.service
Normal file
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=Headphones
|
||||
Wants=network.target network-online.target
|
||||
After=network.target network-online.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
User=__APP__
|
||||
Group=__APP__
|
||||
ExecStart=/usr/bin/python3 __FINALPATH__/Headphones.py -d --datadir __DATADIR__ --nolaunch --config /etc/headphones/headphones.ini --port __PORT__
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
105
manifest.json
105
manifest.json
|
@ -1,100 +1,47 @@
|
|||
{
|
||||
"name": "Headphones",
|
||||
"id": "headphones",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Automatic music downloader",
|
||||
"fr": "Téléchargement automatisé de musique"
|
||||
"en": "Automated music downloader for NZB and Torrent",
|
||||
"fr": "Automated music downloader for NZB and Torrent"
|
||||
},
|
||||
"license": "GPL-3",
|
||||
"version": "0.6.0~ynh1",
|
||||
"url": "https://github.com/rembo10/headphones",
|
||||
"upstream": {
|
||||
"license": "free",
|
||||
"website": "https://github.com/rembo10/headphones",
|
||||
"userdoc": "https://github.com/rembo10/headphones/wiki/Usage-guide",
|
||||
"code": "https://github.com/rembo10/headphones"
|
||||
},
|
||||
"license": "free",
|
||||
"maintainer": {
|
||||
"name": "Snipees",
|
||||
"email": "snipees@wareziens.net",
|
||||
"url": "https://github.com/Snipees"
|
||||
"name": "John doe",
|
||||
"email": "john.doe@example.com"
|
||||
},
|
||||
"multi_instance": "false",
|
||||
"requirements": {
|
||||
"yunohost": ">= 4.3.0"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for Headphones",
|
||||
"fr": "Choisissez un domaine pour Headphones"
|
||||
},
|
||||
"example": "mydomain.org"
|
||||
"type": "domain"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for Headphones",
|
||||
"fr": "Choisissez un chemin pour Headphones"
|
||||
},
|
||||
"type": "path",
|
||||
"example": "/headphones",
|
||||
"default": "/headphones"
|
||||
},
|
||||
{
|
||||
"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 installation method",
|
||||
"fr": "Choisissez le type d'installation"
|
||||
},
|
||||
"choices": ["LOCAL", "REMOTE"],
|
||||
"default": "LOCAL"
|
||||
},
|
||||
{
|
||||
"name": "port",
|
||||
"ask": {
|
||||
"en": "LOCAL: Choose the listening port of the app",
|
||||
"fr": "LOCAL: Choisissez le port d'écoute de l'application"
|
||||
},
|
||||
"example": "8181",
|
||||
"default": "8181"
|
||||
},
|
||||
{
|
||||
"name": "fork",
|
||||
"ask": {
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"name": "options",
|
||||
"ask": {
|
||||
"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"
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
309
scripts/install
309
scripts/install
|
@ -1,155 +1,178 @@
|
|||
#!/bin/bash
|
||||
|
||||
#debug commands
|
||||
#exec > >(tee /tmp/debug-install.log)
|
||||
#exec 2>&1
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Retrieve arguments
|
||||
app_domain=$1
|
||||
app_path=$2
|
||||
app_public=$3
|
||||
app_method=$4
|
||||
app_port=$5
|
||||
app_fork=$6
|
||||
app_opts=$7
|
||||
app_host=$8
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Basic variable declaration
|
||||
BASEDIR="$(dirname "$(pwd)")"
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Common variable declaration
|
||||
app_id=headphones
|
||||
app_user=headphones
|
||||
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"
|
||||
ynh_clean_setup () {
|
||||
### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl $app_domain$app_path -a $app_id
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
exit 1
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..." --time --weight=1
|
||||
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..." --time --weight=1
|
||||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Finding an available port..." --time --weight=1
|
||||
|
||||
# Find an available port
|
||||
port=$(ynh_find_port --port=8181)
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
# ynh_script_progression --message="Installing dependencies..." --time --weight=1
|
||||
|
||||
# ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --time --weight=1
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --time --weight=1
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring NGINX web server..." --time --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# CREATE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a data directory..." --time --weight=1
|
||||
|
||||
datadir=/home/yunohost.app/$app
|
||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
||||
|
||||
mkdir -p $datadir
|
||||
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:www-data "$datadir"
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --time --weight=1
|
||||
|
||||
ynh_add_config --template="some_config_file" --destination="$final_path/some_config_file"
|
||||
|
||||
chmod 400 "$final_path/some_config_file"
|
||||
chown $app:$app "$final_path/some_config_file"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..." --time --weight=1
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring log rotation..." --time --weight=1
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1
|
||||
|
||||
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..." --time --weight=1
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
|
||||
|
||||
# Make install if localhost installation
|
||||
if [[ $app_method == "LOCAL"* ]]; then
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
# Check port availability
|
||||
sudo yunohost app checkport $app_port
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
# Make directories
|
||||
sudo mkdir -p $app_logs_dir
|
||||
sudo mkdir -p $app_data_dir
|
||||
sudo mkdir -p $app_install_dir
|
||||
|
||||
# Install latest version of app using the fork
|
||||
sudo apt-get install -y git-core
|
||||
sudo git clone $app_fork $app_install_dir
|
||||
|
||||
# Install dependencies (using virtualenv)
|
||||
if [[ $(python --version 2>&1) != Python\ 2* ]]; then
|
||||
app_python_bin=$app_install_dir/bin/python
|
||||
sudo apt-get install -y python-pip python-virtualenv python-dev uwsgi uwsgi-plugin-python
|
||||
sudo virtualenv $app_install_dir
|
||||
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_data_dir --shell /bin/false $app_user
|
||||
|
||||
# Configure daemon
|
||||
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" $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
|
||||
*"Transmission"*)
|
||||
ref_file=$(sudo sed -n -e '/^CONFIG_DIR/ s/.*\= *//p' $(find /etc/default -name '*transmission*') | sed 's/["* ]//g')/settings.json
|
||||
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" $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
|
||||
|
||||
# Set rights
|
||||
sudo chown -R $app_user $app_install_dir
|
||||
sudo chown -R $app_user $app_data_dir
|
||||
sudo chown -R $app_user $app_logs_dir
|
||||
sudo chmod +x /etc/init.d/$app_id
|
||||
sudo chmod +x -R $app_install_dir
|
||||
sudo chmod +x -R $app_data_dir
|
||||
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"
|
||||
|
||||
# Start daemon at boot
|
||||
sudo update-rc.d $app_id defaults
|
||||
|
||||
# Start service
|
||||
sudo service $app_id start
|
||||
|
||||
# Set proxy host variable
|
||||
app_host="http://${app_local_host}:${app_port}${app_path%/}"
|
||||
|
||||
fi
|
||||
|
||||
|
||||
# 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
|
||||
# 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
|
||||
sudo service nginx reload
|
||||
sudo yunohost app ssowatconf
|
||||
ynh_script_progression --message="Installation of $app completed" --time --last
|
||||
|
|
124
scripts/remove
124
scripts/remove
|
@ -1,56 +1,102 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 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}"
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Retrieve arguments
|
||||
app_method="$(sudo yunohost app setting ${app_id} method)"
|
||||
app_domain="$(sudo yunohost app setting ${app_id} domain)"
|
||||
keep_data=$1
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
|
||||
# Remove files if localhost installation
|
||||
if [[ $app_method == "LOCAL"* ]]; then
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Kill app and remove from boot
|
||||
sudo service $app_id stop
|
||||
sudo killall $app_id
|
||||
sudo update-rc.d $app_id remove
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
|
||||
# Delete app user
|
||||
sudo deluser $app_user
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||
#=================================================
|
||||
|
||||
# Remove sources
|
||||
sudo rm -rf $app_install_dir
|
||||
|
||||
# Remove logs
|
||||
if [[ $app_logs_dir != "$app_data_dir"* ]]; then
|
||||
sudo rm -rf $app_logs_dir
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app service integration..." --time --weight=1
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
# Remove data
|
||||
if [[ $keep_data == "No" ]]; then
|
||||
sudo rm -rf $app_data_dir
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..." --time --weight=1
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE DATA DIR
|
||||
#=================================================
|
||||
|
||||
# Remove the data directory if --purge option is used
|
||||
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
|
||||
then
|
||||
ynh_script_progression --message="Removing app data directory..." --time --weight=1
|
||||
ynh_secure_remove --file="$datadir"
|
||||
fi
|
||||
|
||||
# Remove daemon config
|
||||
sudo rm -f /etc/init.d/$app_id
|
||||
sudo rm -f /etc/default/$app_id
|
||||
sudo rm -rf /var/run/$app_id
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --time --weight=1
|
||||
|
||||
fi
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
# ynh_script_progression --message="Removing dependencies..." --time --weight=1
|
||||
|
||||
# Remove Nginx parameters
|
||||
sudo rm -f /etc/nginx/conf.d/$app_domain.d/$app_id.conf
|
||||
# # Remove metapackage and its dependencies
|
||||
# ynh_remove_app_dependencies
|
||||
|
||||
# Remove Yunohost service
|
||||
sudo yunohost service remove $app_id
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
|
||||
|
||||
# Reload Nginx and update Yunohost
|
||||
sudo service nginx reload
|
||||
sudo yunohost app ssowatconf
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --time --last
|
||||
|
|
Loading…
Reference in a new issue