mirror of
https://github.com/YunoHost-Apps/archivebox_ynh.git
synced 2024-09-03 18:15:54 +02:00
cleaning
This commit is contained in:
parent
8c96a41be2
commit
645d194f75
6 changed files with 59 additions and 164 deletions
|
@ -68,4 +68,4 @@ ram.runtime = "50M"
|
|||
main.url = "/"
|
||||
|
||||
[resources.apt]
|
||||
packages = "python3-venv expect apt-transport-https ca-certificates gnupg2 zlib1g-dev dumb-init gosu cron unzip curl fontconfig fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-symbola fonts-noto fonts-freefont-ttf wget curl chromium git ffmpeg youtube-dl ripgrep build-essential python3-dev"
|
||||
packages = "python3-venv, expect, apt-transport-https, ca-certificates, gnupg2, zlib1g-dev, dumb-init, gosu, unzip, curl, fontconfig, fonts-ipafont-gothic, fonts-wqy-zenhei, fonts-thai-tlwg, fonts-kacst, fonts-symbola, fonts-noto, fonts-freefont-ttf, wget, curl, chromium, ffmpeg, youtube-dl, ripgrep, build-essential, python3-dev"
|
||||
|
|
|
@ -28,23 +28,13 @@ ynh_backup --src_path="$install_dir"
|
|||
ynh_backup --src_path="$data_dir" --is_big
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -35,14 +35,6 @@ mkdir -p $install_dir
|
|||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
|
@ -69,7 +61,7 @@ archivebox_cmd="$install_dir/venv/bin/archivebox"
|
|||
#=================================================
|
||||
# INSTALL NODE DEPENDENCIES
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Installing node dependencies..."
|
||||
ynh_script_progression --message="Installing node dependencies..."
|
||||
|
||||
cp -f $tempdir/package.json "$install_dir/package.json"
|
||||
cp -f $tempdir/package-lock.json "$install_dir/package-lock.json"
|
||||
|
@ -84,7 +76,7 @@ popd
|
|||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
|
||||
ynh_add_config --template="../conf/ArchiveBox.conf" --destination="$data_dir/ArchiveBox.conf"
|
||||
ynh_add_config --template="ArchiveBox.conf" --destination="$data_dir/ArchiveBox.conf"
|
||||
|
||||
chmod 600 "$data_dir/ArchiveBox.conf"
|
||||
chown $app:$app "$data_dir/ArchiveBox.conf"
|
||||
|
@ -92,7 +84,7 @@ chown $app:$app "$data_dir/ArchiveBox.conf"
|
|||
#=================================================
|
||||
# INITIALIZE ARCHIVEBOX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Initializing Archivebox" --weight=1
|
||||
ynh_script_progression --message="Initializing $app" --weight=1
|
||||
|
||||
pushd $data_dir
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $archivebox_cmd init
|
||||
|
@ -116,7 +108,7 @@ send -- "$password\r"
|
|||
expect eof
|
||||
EOF
|
||||
else
|
||||
ynh_script_progression --message="Creating new archivebox superuser: $admin" --weight=1
|
||||
ynh_script_progression --message="Creating new Archivebox superuser: $admin" --weight=1
|
||||
ynh_exec_as $app /usr/bin/expect<<EOF
|
||||
set force_conservative 0 ;
|
||||
set timeout -1
|
||||
|
@ -135,28 +127,19 @@ EOF
|
|||
popd
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring log rotation..." --weight=1
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add $app --description="Self-hosted internet archiving" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -10,10 +10,9 @@ source _common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
|
||||
# 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
|
||||
|
@ -22,37 +21,15 @@ then
|
|||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing various files..." --weight=1
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
|
||||
|
|
|
@ -39,49 +39,31 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
|||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
|
||||
yunohost service add $app --description="Self-hosted internet archiving" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
|
||||
|
||||
mkdir -p /var/log/$app
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add $app --description="Self-hosted internet archiving" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX" --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
|
|
115
scripts/upgrade
115
scripts/upgrade
|
@ -9,12 +9,6 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
|
@ -27,16 +21,12 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
|||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
tempdir="$(mktemp -d)"
|
||||
ynh_setup_source --dest_dir="$tempdir"
|
||||
mkdir -p $install_dir
|
||||
fi
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
tempdir="$(mktemp -d)"
|
||||
ynh_setup_source --dest_dir="$tempdir"
|
||||
mkdir -p $install_dir
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
@ -48,57 +38,42 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
|||
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# UPGRADE VIA PIP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading via pip" --weight=1
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading via pip" --weight=1
|
||||
ynh_use_nodejs
|
||||
python3 -m venv "${install_dir}/venv"
|
||||
cp ../conf/requirements.txt "$install_dir/requirements.txt"
|
||||
chown -R "$app" "$install_dir"
|
||||
ynh_use_nodejs
|
||||
python3 -m venv "${install_dir}/venv"
|
||||
cp ../conf/requirements.txt "$install_dir/requirements.txt"
|
||||
chown -R "$app" "$install_dir"
|
||||
|
||||
#run source in a 'sub shell'
|
||||
(
|
||||
set +o nounset
|
||||
source "${install_dir}/venv/bin/activate"
|
||||
set -o nounset
|
||||
ynh_exec_as $app $install_dir/venv/bin/pip install --upgrade pip
|
||||
ynh_exec_as $app $install_dir/venv/bin/pip install -r "$install_dir/requirements.txt"
|
||||
)
|
||||
#run source in a 'sub shell'
|
||||
(
|
||||
set +o nounset
|
||||
source "${install_dir}/venv/bin/activate"
|
||||
set -o nounset
|
||||
ynh_exec_as $app $install_dir/venv/bin/pip install --upgrade pip
|
||||
ynh_exec_as $app $install_dir/venv/bin/pip install -r "$install_dir/requirements.txt"
|
||||
)
|
||||
|
||||
# we use this virtualenv archivebox for further commands now
|
||||
archivebox_cmd="$install_dir/venv/bin/archivebox"
|
||||
fi
|
||||
# we use this virtualenv archivebox for further commands now
|
||||
archivebox_cmd="$install_dir/venv/bin/archivebox"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE NODE DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading node dependencies..."
|
||||
ynh_script_progression --message="Upgrading node dependencies..."
|
||||
|
||||
cp -f $tempdir/package.json "$install_dir/package.json"
|
||||
cp -f $tempdir/package-lock.json "$install_dir/package-lock.json"
|
||||
ynh_secure_remove --file="$tempdir"
|
||||
pushd $install_dir
|
||||
ynh_use_nodejs
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm ci
|
||||
popd
|
||||
fi
|
||||
cp -f $tempdir/package.json "$install_dir/package.json"
|
||||
cp -f $tempdir/package-lock.json "$install_dir/package-lock.json"
|
||||
ynh_secure_remove --file="$tempdir"
|
||||
pushd $install_dir
|
||||
ynh_use_nodejs
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm ci
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
|
@ -106,7 +81,7 @@ fi
|
|||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||
|
||||
ynh_store_file_checksum --file="$data_dir/ArchiveBox.conf"
|
||||
ynh_add_config --template="../conf/ArchiveBox.conf" --destination="$data_dir/ArchiveBox.conf"
|
||||
ynh_add_config --template="ArchiveBox.conf" --destination="$data_dir/ArchiveBox.conf"
|
||||
|
||||
chmod 600 "$data_dir/ArchiveBox.conf"
|
||||
chown $app:$app "$data_dir/ArchiveBox.conf"
|
||||
|
@ -115,38 +90,26 @@ chown $app:$app "$data_dir/ArchiveBox.conf"
|
|||
# FINISH ARCHIVEBOX SETUP
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
# rerun archivebox setup (its idempotent, so it should be ok during upgrade)
|
||||
ynh_script_progression --message="Finishing Archivebox Setup" --weight=1
|
||||
pushd $data_dir
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $archivebox_cmd init --setup
|
||||
popd
|
||||
fi
|
||||
# rerun archivebox setup (its idempotent, so it should be ok during upgrade)
|
||||
ynh_script_progression --message="Finishing Archivebox Setup" --weight=1
|
||||
pushd $data_dir
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $archivebox_cmd init --setup
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add $app --description="Self-hosted internet archiving" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue