mirror of
https://github.com/YunoHost-Apps/archivebox_ynh.git
synced 2024-09-03 18:15:54 +02:00
commit
bb56a7a052
22 changed files with 335 additions and 2391 deletions
109
.github/workflows/updater.sh
vendored
Normal file
109
.github/workflows/updater.sh
vendored
Normal file
|
@ -0,0 +1,109 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# PACKAGE UPDATING HELPER
|
||||
#=================================================
|
||||
|
||||
# This script is meant to be run by GitHub Actions
|
||||
# The YunoHost-Apps organisation offers a template Action to run this script periodically
|
||||
# Since each app is different, maintainers can adapt its contents so as to perform
|
||||
# automatic actions when a new upstream release is detected.
|
||||
|
||||
#=================================================
|
||||
# FETCHING LATEST RELEASE AND ITS ASSETS
|
||||
#=================================================
|
||||
|
||||
# Fetching information
|
||||
current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
|
||||
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
|
||||
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
|
||||
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
|
||||
assets="https://github.com/ArchiveBox/ArchiveBox/archive/refs/tags/$version.tar.gz"
|
||||
|
||||
# Later down the script, we assume the version has only digits and dots
|
||||
# Sometimes the release name starts with a "v", so let's filter it out.
|
||||
# You may need more tweaks here if the upstream repository has different naming conventions.
|
||||
if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then
|
||||
version=${version:1}
|
||||
fi
|
||||
|
||||
# Setting up the environment variables
|
||||
echo "Current version: $current_version"
|
||||
echo "Latest release from upstream: $version"
|
||||
echo "VERSION=$version" >> $GITHUB_ENV
|
||||
echo "REPO=$repo" >> $GITHUB_ENV
|
||||
# For the time being, let's assume the script will fail
|
||||
echo "PROCEED=false" >> $GITHUB_ENV
|
||||
|
||||
# Proceed only if the retrieved version is greater than the current one
|
||||
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
|
||||
echo "::warning ::No new version available"
|
||||
exit 0
|
||||
# Proceed only if a PR for this new version does not already exist
|
||||
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
|
||||
echo "::warning ::A branch already exists for this update"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# UPDATE SOURCE FILES
|
||||
#=================================================
|
||||
|
||||
# Let's download source tarball
|
||||
asset_url=$assets
|
||||
|
||||
echo "Handling asset at $asset_url"
|
||||
|
||||
src="app"
|
||||
|
||||
# Create the temporary directory
|
||||
tempdir="$(mktemp -d)"
|
||||
|
||||
# Download sources and calculate checksum
|
||||
filename=${asset_url##*/}
|
||||
curl --silent -4 -L $asset_url -o "$tempdir/$filename"
|
||||
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
|
||||
|
||||
# Delete temporary directory
|
||||
rm -rf $tempdir
|
||||
|
||||
# Get extension
|
||||
if [[ $filename == *.tar.gz ]]; then
|
||||
extension=tar.gz
|
||||
else
|
||||
extension=${filename##*.}
|
||||
fi
|
||||
|
||||
# Rewrite source file
|
||||
cat <<EOT > conf/$src.src
|
||||
SOURCE_URL=$asset_url
|
||||
SOURCE_SUM=$checksum
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=$extension
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
SOURCE_EXTRACT=true
|
||||
EOT
|
||||
echo "... conf/$src.src updated"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPDATE STEPS
|
||||
#=================================================
|
||||
|
||||
# Any action on the app's source code can be done.
|
||||
# The GitHub Action workflow takes care of committing all changes after this script ends.
|
||||
|
||||
sed -i "/archivebox==/c\archivebox==$version;" conf/requirements.txt
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
# Replace new version in manifest
|
||||
echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json
|
||||
|
||||
# No need to update the README, yunohost-bot takes care of it
|
||||
|
||||
# The Action will proceed only if the PROCEED environment variable is set to true
|
||||
echo "PROCEED=true" >> $GITHUB_ENV
|
||||
exit 0
|
49
.github/workflows/updater.yml
vendored
Normal file
49
.github/workflows/updater.yml
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected.
|
||||
# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization.
|
||||
# This file should be enough by itself, but feel free to tune it to your needs.
|
||||
# It calls updater.sh, which is where you should put the app-specific update steps.
|
||||
name: Check for new upstream releases
|
||||
on:
|
||||
# Allow to manually trigger the workflow
|
||||
workflow_dispatch:
|
||||
# Run it every day at 6:00 UTC
|
||||
schedule:
|
||||
- cron: '0 6 * * *'
|
||||
jobs:
|
||||
updater:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Fetch the source code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run the updater script
|
||||
id: run_updater
|
||||
run: |
|
||||
# Setting up Git user
|
||||
git config --global user.name 'yunohost-bot'
|
||||
git config --global user.email 'yunohost-bot@users.noreply.github.com'
|
||||
# Run the updater script
|
||||
/bin/bash .github/workflows/updater.sh
|
||||
- name: Commit changes
|
||||
id: commit
|
||||
if: ${{ env.PROCEED == 'true' }}
|
||||
run: |
|
||||
git commit -am "Upgrade to v$VERSION"
|
||||
- name: Create Pull Request
|
||||
id: cpr
|
||||
if: ${{ env.PROCEED == 'true' }}
|
||||
uses: peter-evans/create-pull-request@v3
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit-message: Update to version ${{ env.VERSION }}
|
||||
committer: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
|
||||
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
|
||||
signoff: false
|
||||
base: testing
|
||||
branch: ci-auto-update-v${{ env.VERSION }}
|
||||
delete-branch: true
|
||||
title: 'Upgrade to version ${{ env.VERSION }}'
|
||||
body: |
|
||||
Upgrade to v${{ env.VERSION }}
|
||||
draft: false
|
|
@ -18,7 +18,8 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
|
|||
Archiving solution to collect, save, and view sites you want to preserve offline
|
||||
|
||||
|
||||
**Shipped version:** 0.6.2~ynh9
|
||||
**Shipped version:** 0.6.2~ynh11
|
||||
|
||||
|
||||
**Demo:** https://archiveboxdemo.commoninternet.net
|
||||
|
||||
|
@ -32,6 +33,8 @@ Archiving solution to collect, save, and view sites you want to preserve offline
|
|||
* required to be run at the base path / , subpaths not yet supported
|
||||
* currently only tested on amd64
|
||||
* haven't yet implemented single-sign or LDAP integration
|
||||
* require a SSE3 instructions
|
||||
* will install chromium as requirement
|
||||
|
||||
## Documentation and resources
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
|
|||
Archiving solution to collect, save, and view sites you want to preserve offline
|
||||
|
||||
|
||||
**Version incluse :** 0.6.2~ynh9
|
||||
**Version incluse :** 0.6.2~ynh11
|
||||
|
||||
|
||||
**Démo :** https://archiveboxdemo.commoninternet.net
|
||||
|
||||
|
@ -32,6 +33,8 @@ Archiving solution to collect, save, and view sites you want to preserve offline
|
|||
* required to be run at the base path / , subpaths not yet supported
|
||||
* currently only tested on amd64
|
||||
* haven't yet implemented single-sign or LDAP integration
|
||||
* require a SSE3 instructions
|
||||
* will install chromium as requirement
|
||||
|
||||
## Documentations et ressources
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
; Manifest
|
||||
domain="domain.tld"
|
||||
path="/path"
|
||||
admin="john"
|
||||
language="fr"
|
||||
is_public=1
|
||||
language="fr"
|
||||
admin="john"
|
||||
password="1Strong-Password"
|
||||
port="666"
|
||||
; Checks
|
||||
|
@ -16,7 +16,9 @@
|
|||
setup_public=1
|
||||
upgrade=1
|
||||
# 0.6.2~ynh9
|
||||
upgrade=1 from_commit=a2d626f966bc358aea53bbe78d9fa2a0e3783c78
|
||||
upgrade=0 from_commit=a2d626f966bc358aea53bbe78d9fa2a0e3783c78
|
||||
# 0.6.2~ynh10
|
||||
upgrade=1 from_commit=719751ec9342e287d65f159349217fe0d498c294
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
port_already_use=0
|
||||
|
@ -24,6 +26,3 @@
|
|||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=a2d626f966bc358aea53bbe78d9fa2a0e3783c78
|
||||
name=0.6.2~ynh9
|
||||
|
|
7
conf/app.src
Normal file
7
conf/app.src
Normal file
|
@ -0,0 +1,7 @@
|
|||
SOURCE_URL=https://github.com/ArchiveBox/ArchiveBox/archive/refs/tags/v0.6.2.tar.gz
|
||||
SOURCE_SUM=53a6dd88d2a7c1510bccd172e7b89689a722acbdcc843d46d7f37efba8c7369d
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
SOURCE_EXTRACT=true
|
|
@ -1,13 +1,7 @@
|
|||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||
location __PATH__/ {
|
||||
|
||||
proxy_set_header Accept-Encoding "";
|
||||
try_files $uri @proxy;
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
|
||||
location @proxy {
|
||||
proxy_pass http://127.0.0.1:__PORT__;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
|
@ -16,4 +10,7 @@ location @proxy {
|
|||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header Proxy "";
|
||||
proxy_pass_header Server;
|
||||
}
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
|
|
2252
conf/package-lock.json
generated
2252
conf/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"name": "archivebox",
|
||||
"version": "0.6.3",
|
||||
"description": "ArchiveBox: The self-hosted internet archive",
|
||||
"author": "Nick Sweeting <archivebox-npm@sweeting.me>",
|
||||
"repository": "github:ArchiveBox/ArchiveBox",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@postlight/mercury-parser": "^2.2.0",
|
||||
"readability-extractor": "git+https://github.com/ArchiveBox/readability-extractor.git",
|
||||
"single-file": "git+https://github.com/gildas-lormeau/SingleFile.git"
|
||||
}
|
||||
}
|
|
@ -1 +1 @@
|
|||
archivebox==0.6.2;
|
||||
archivebox==0.6.2;
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
source __FINALPATH__/venv/bin/activate
|
||||
__FINALPATH__/venv/bin/archivebox server __PORT__
|
|
@ -7,7 +7,8 @@ Type=simple
|
|||
User=__APP__
|
||||
Group=__APP__
|
||||
WorkingDirectory=__DATADIR__/
|
||||
ExecStart=__FINALPATH__/start.sh
|
||||
Environment="__YNH_NODE_LOAD_PATH__"
|
||||
ExecStart=__FINALPATH__/venv/bin/archivebox server 127.0.0.1:__PORT__
|
||||
StandardOutput=append:/var/log/__APP__/__APP__.log
|
||||
StandardError=inherit
|
||||
|
||||
|
|
|
@ -2,3 +2,5 @@
|
|||
* required to be run at the base path / , subpaths not yet supported
|
||||
* currently only tested on amd64
|
||||
* haven't yet implemented single-sign or LDAP integration
|
||||
* require a SSE3 instructions
|
||||
* will install chromium as requirement
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"en": "Archiving solution to collect, save, and view sites you want to preserve offline",
|
||||
"fr": "Solution d'archivage pour collecter, enregistrer et afficher les sites que vous souhaitez conserver hors ligne"
|
||||
},
|
||||
"version": "0.6.2~ynh9",
|
||||
"version": "0.6.2~ynh11",
|
||||
"url": "https://archivebox.io/",
|
||||
"upstream": {
|
||||
"license": "MIT",
|
||||
|
@ -33,10 +33,6 @@
|
|||
"name": "domain",
|
||||
"type": "domain"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
|
@ -52,15 +48,22 @@
|
|||
"en": "Choose the application language",
|
||||
"fr": "Choisissez la langue de l'application"
|
||||
},
|
||||
"choices": ["fr", "en"],
|
||||
"choices": [
|
||||
"fr",
|
||||
"en"
|
||||
],
|
||||
"default": "fr"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user"
|
||||
},
|
||||
{
|
||||
"name": "password",
|
||||
"type": "password",
|
||||
"help": {
|
||||
"en": "The password used to login as an admin for this app",
|
||||
"fr": "Le mot de passe utilisé pour se connecter en tant qu'administrateur pour cette application"
|
||||
"en": "Choose wisely a password that is different from the username and does not contain the `$` symbol.",
|
||||
"fr": "Choisissez judicieusement un mot de passe différent du nom d'utilisateur et ne contenant pas le symbole `$`."
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
# dependencies used by the app
|
||||
# dependencies used by the app (must be on a single line)
|
||||
pkg_dependencies="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 \
|
||||
|
|
|
@ -28,13 +28,14 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
|
|||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
|
||||
# Add settings here as needed by your application
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
|
||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
|
|
|
@ -28,19 +28,19 @@ domain=$YNH_APP_ARG_DOMAIN
|
|||
# we can only add support for subpaths once this is resolved in archivebox
|
||||
# https://github.com/ArchiveBox/ArchiveBox/issues/724
|
||||
path_url="/"
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
language=$YNH_APP_ARG_LANGUAGE
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
password=$YNH_APP_ARG_PASSWORD
|
||||
|
||||
admin_mail=$(ynh_user_get_info $admin 'mail')
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
admin_mail=$(ynh_user_get_info $admin 'mail')
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
@ -51,12 +51,12 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
|||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
|
@ -74,9 +74,8 @@ ynh_app_setting_set --app=$app --key=port --value=$port
|
|||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=8
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
|
@ -87,13 +86,14 @@ ynh_script_progression --message="Configuring system user..." --weight=1
|
|||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# CREATE FINAL_PATH FOLDER
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=1
|
||||
ynh_script_progression --message="Setting up source files..." --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"
|
||||
tempdir="$(mktemp -d)"
|
||||
ynh_setup_source --dest_dir="$tempdir"
|
||||
mkdir -p $final_path
|
||||
|
||||
chmod 750 "$final_path"
|
||||
|
@ -103,7 +103,7 @@ chown -R $app:www-data "$final_path"
|
|||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
||||
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
@ -113,12 +113,10 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# PIP INSTALLATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Install project via pip..." --weight=80
|
||||
ynh_script_progression --message="Installing project via pip..." --weight=80
|
||||
|
||||
python3 -m venv "${final_path}/venv"
|
||||
cp ../conf/requirements.txt "$final_path/requirements.txt"
|
||||
ynh_add_config --template="../conf/start.sh" --destination="$final_path/start.sh"
|
||||
chmod 760 "$final_path/start.sh"
|
||||
chown -R "$app" "$final_path"
|
||||
|
||||
#run source in a 'sub shell'
|
||||
|
@ -136,16 +134,16 @@ archivebox_cmd="$final_path/venv/bin/archivebox"
|
|||
#=================================================
|
||||
# INSTALL NODE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Install node dependencies..."
|
||||
ynh_script_progression --message="Installing node dependencies..."
|
||||
|
||||
cp ../conf/package.json "$final_path/package.json"
|
||||
cp ../conf/package-lock.json "$final_path/package-lock.json"
|
||||
cp -f $tempdir/package.json "$final_path/package.json"
|
||||
cp -f $tempdir/package-lock.json "$final_path/package-lock.json"
|
||||
ynh_secure_remove --file="$tempdir"
|
||||
pushd $final_path
|
||||
ynh_npm ci
|
||||
ynh_use_nodejs
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm ci
|
||||
popd
|
||||
|
||||
ynh_node_path=$ynh_node
|
||||
|
||||
#=================================================
|
||||
# CREATE DATA DIRECTORY
|
||||
#=================================================
|
||||
|
@ -161,32 +159,31 @@ chmod -R o-rwx "$datadir"
|
|||
chown -R $app:www-data "$datadir"
|
||||
|
||||
#=================================================
|
||||
# CREATE ARCHIVEBOX CONFIG
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
|
||||
# copy configuration file
|
||||
ynh_add_config --template="../conf/ArchiveBox.conf" --destination="$datadir/ArchiveBox.conf"
|
||||
|
||||
# permissions
|
||||
chmod 750 "$datadir"
|
||||
chmod -R o-rwx "$datadir"
|
||||
chown -R $app:www-data "$datadir"
|
||||
chmod 600 "$datadir/ArchiveBox.conf"
|
||||
chown $app:$app "$datadir/ArchiveBox.conf"
|
||||
|
||||
#=================================================
|
||||
# INITIALIZE ARCHIVEBOX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Initializing Archivebox" --weight=1
|
||||
|
||||
cd $datadir && ynh_exec_as $app $archivebox_cmd init
|
||||
pushd $datadir
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $archivebox_cmd init
|
||||
|
||||
ynh_script_progression --message="Checking if admin superuser already exists: $admin" --weight=1
|
||||
USER_EXISTS=$(cd $datadir && ynh_exec_as $app $archivebox_cmd manage shell -c "from django.contrib.auth.models import User; print(User.objects.filter(username='$admin').count())")
|
||||
ynh_script_progression --message="Found users: $USER_EXISTS" --weight=1
|
||||
ynh_script_progression --message="Checking if admin superuser already exists: $admin" --weight=1
|
||||
USER_EXISTS=$(ynh_exec_as $app $archivebox_cmd manage shell -c "from django.contrib.auth.models import User; print(User.objects.filter(username='$admin').count())")
|
||||
ynh_script_progression --message="Found users: $USER_EXISTS" --weight=1
|
||||
|
||||
if [ $USER_EXISTS -eq 1 ]
|
||||
then
|
||||
ynh_script_progression --message="User already exists: setting admin password" --weight=1
|
||||
ynh_exec_as $app /usr/bin/expect<<EOF
|
||||
if [ $USER_EXISTS -eq 1 ]
|
||||
then
|
||||
ynh_script_progression --message="User already exists: setting admin password" --weight=1
|
||||
ynh_exec_as $app /usr/bin/expect<<EOF
|
||||
set force_conservative 0 ;
|
||||
set timeout -1
|
||||
spawn sh -c "cd $datadir && $archivebox_cmd manage changepassword $admin"
|
||||
|
@ -197,9 +194,9 @@ expect "*?assword (again): "
|
|||
send -- "$password\r"
|
||||
expect eof
|
||||
EOF
|
||||
else
|
||||
ynh_script_progression --message="Creating new archivebox superuser: $admin" --weight=1
|
||||
ynh_exec_as $app /usr/bin/expect<<EOF
|
||||
else
|
||||
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
|
||||
spawn sh -c "cd $datadir && $archivebox_cmd manage createsuperuser --username $admin --email $admin_mail"
|
||||
|
@ -210,10 +207,11 @@ expect "*?assword (again): "
|
|||
send -- "$password\r"
|
||||
expect eof
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Finishing Archivebox Setup" --weight=1
|
||||
cd $datadir && ynh_exec_as $app $ynh_node_load_PATH $archivebox_cmd init --setup
|
||||
ynh_script_progression --message="Finishing Archivebox Setup" --weight=1
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $archivebox_cmd init --setup
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
|
|
|
@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -32,14 +32,14 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
|||
# 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..." --weight=1
|
||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
@ -47,7 +47,7 @@ ynh_remove_systemd_config
|
|||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
@ -55,7 +55,7 @@ ynh_remove_logrotate
|
|||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
@ -67,14 +67,14 @@ ynh_secure_remove --file="$final_path"
|
|||
# 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..."
|
||||
ynh_script_progression --message="Removing app data directory..." --weight=1
|
||||
ynh_secure_remove --file="$datadir"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
@ -82,17 +82,17 @@ ynh_remove_nginx_config
|
|||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
ynh_exec_warn_less ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing various files..." --weight=1
|
||||
ynh_script_progression --message="Removing various files..." --weight=1
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
|
@ -102,7 +102,7 @@ ynh_secure_remove --file="/var/log/$app"
|
|||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
|
@ -111,4 +111,4 @@ ynh_system_user_delete --username=$app
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
|
|
|
@ -23,7 +23,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -35,20 +35,13 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
|
@ -89,9 +82,15 @@ chown -R $app:www-data "$datadir"
|
|||
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
|
|
|
@ -21,21 +21,16 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|||
# we can only add support for subpaths once this is resolved in archivebox
|
||||
# https://github.com/ArchiveBox/ArchiveBox/issues/724
|
||||
path_url="/"
|
||||
language=$(ynh_app_setting_get --app=$app --key=language)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
language=$(ynh_app_setting_get --app=$app --key=language)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||
|
||||
#=================================================
|
||||
# SET CORRECT NODE VERSION
|
||||
#=================================================
|
||||
ynh_use_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking version..."
|
||||
ynh_script_progression --message="Checking version..." --weight=1
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
|
@ -82,6 +77,32 @@ ynh_script_progression --message="Making sure dedicated system user exists..." -
|
|||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
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 $final_path
|
||||
fi
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -91,17 +112,7 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
|
|||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
if [ $nodejs_version != $(ynh_app_setting_get --app=$app --key=nodejs_version) ]; then
|
||||
ynh_remove_nodejs
|
||||
ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
fi
|
||||
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# UPGRADE VIA PIP
|
||||
#=================================================
|
||||
|
@ -109,6 +120,7 @@ fi
|
|||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading via pip" --weight=1
|
||||
ynh_use_nodejs
|
||||
python3 -m venv "${final_path}/venv"
|
||||
cp ../conf/requirements.txt "$final_path/requirements.txt"
|
||||
chown -R "$app" "$final_path"
|
||||
|
@ -124,15 +136,48 @@ then
|
|||
|
||||
# we use this virtualenv archivebox for further commands now
|
||||
archivebox_cmd="$final_path/venv/bin/archivebox"
|
||||
|
||||
# rerun archivebox setup (its idempotent, so it should be ok during upgrade)
|
||||
ynh_script_progression --message="Finishing Archivebox Setup" --weight=1
|
||||
cd $datadir && ynh_exec_as $app $ynh_node_load_PATH $archivebox_cmd init --setup
|
||||
fi
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
#=================================================
|
||||
# UPGRADE NODE DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading node dependencies..."
|
||||
|
||||
cp -f $tempdir/package.json "$final_path/package.json"
|
||||
cp -f $tempdir/package-lock.json "$final_path/package-lock.json"
|
||||
ynh_secure_remove --file="$tempdir"
|
||||
pushd $final_path
|
||||
ynh_use_nodejs
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm ci
|
||||
popd
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||
|
||||
ynh_store_file_checksum --file="$datadir/ArchiveBox.conf"
|
||||
ynh_add_config --template="../conf/ArchiveBox.conf" --destination="$datadir/ArchiveBox.conf"
|
||||
|
||||
chmod 600 "$datadir/ArchiveBox.conf"
|
||||
chown $app:$app "$datadir/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 $datadir
|
||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $archivebox_cmd init --setup
|
||||
popd
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
|
|
2
sources/extra_files/app/.gitignore
vendored
2
sources/extra_files/app/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
*~
|
||||
*.sw[op]
|
2
sources/patches/.gitignore
vendored
2
sources/patches/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
*~
|
||||
*.sw[op]
|
Loading…
Reference in a new issue