mirror of
https://github.com/YunoHost-Apps/pleroma_ynh.git
synced 2024-09-03 20:15:59 +02:00
commit
3e88dd59d8
19 changed files with 323 additions and 571 deletions
|
@ -25,7 +25,7 @@ For user friendly details about Pleroma: [see here](https://blog.soykaf.com/post
|
||||||
- Tootdon (Android + iOS)
|
- Tootdon (Android + iOS)
|
||||||
- Tootle (iOS)
|
- Tootle (iOS)
|
||||||
|
|
||||||
**Shipped version:** 0.9.99999
|
**Shipped version:** 1.1.7
|
||||||
|
|
||||||
## Important points to read before installing
|
## Important points to read before installing
|
||||||
|
|
||||||
|
@ -85,7 +85,6 @@ The app can be used by multiple users.
|
||||||
|
|
||||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/pleroma/)
|
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/pleroma/)
|
||||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/pleroma/)
|
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/pleroma/)
|
||||||
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/pleroma/)
|
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
|
@ -103,7 +102,6 @@ The app can be used by multiple users.
|
||||||
Developers info
|
Developers info
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
|
|
||||||
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/pleroma_ynh/tree/testing).
|
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/pleroma_ynh/tree/testing).
|
||||||
|
|
||||||
To try the testing branch, please proceed like that.
|
To try the testing branch, please proceed like that.
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
admin="john" (USER)
|
admin="john" (USER)
|
||||||
is_public=1 (PUBLIC|public=1|private=0)
|
is_public=1 (PUBLIC|public=1|private=0)
|
||||||
password="pass"
|
password="pass"
|
||||||
name="My Pleroma"
|
name="My_Pleroma"
|
||||||
registration=0 (BOOLEAN)
|
registration=0 (BOOLEAN)
|
||||||
cache=1 (BOOLEAN)
|
cache=1 (BOOLEAN)
|
||||||
size="5g"
|
size="5g"
|
||||||
|
@ -21,9 +21,9 @@
|
||||||
setup_private=1
|
setup_private=1
|
||||||
setup_public=1
|
setup_public=1
|
||||||
upgrade=1
|
upgrade=1
|
||||||
upgrade=1 from_commit=14d3be2f782048e64696cef85f4fb7dff1ab6181
|
upgrade=1 from_commit=edf199768f57000f4df6e2c704483e1036a78203
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=1
|
multi_instance=0
|
||||||
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
|
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
|
||||||
# incorrect_path=1
|
# incorrect_path=1
|
||||||
port_already_use=0
|
port_already_use=0
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
SOURCE_URL=https://git.pleroma.social/pleroma/pleroma/-/archive/v0.9.99999/pleroma-v0.9.99999.tar.gz
|
|
||||||
SOURCE_SUM=b79ee12d598a162bc16ebd7ec18ee7b0b78cb623574757ad6a0fe19d6a5a23d4
|
|
||||||
SOURCE_SUM_PRG=sha256sum
|
|
||||||
SOURCE_FORMAT=tar.gz
|
|
||||||
SOURCE_IN_SUBDIR=true
|
|
||||||
SOURCE_FILENAME=
|
|
6
conf/arm.src
Normal file
6
conf/arm.src
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
SOURCE_URL=https://git.pleroma.social/pleroma/pleroma/-/jobs/84826/artifacts/download
|
||||||
|
SOURCE_SUM=aeb527340dbecc5056cd3aca459ed0a0f3b41808afc492e61f998032e5c3d874
|
||||||
|
SOURCE_SUM_PRG=sha256sum
|
||||||
|
SOURCE_FORMAT=zip
|
||||||
|
SOURCE_IN_SUBDIR=true
|
||||||
|
SOURCE_FILENAME=pleroma-v1.1.7-arm.zip
|
6
conf/arm64.src
Normal file
6
conf/arm64.src
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
SOURCE_URL=https://git.pleroma.social/pleroma/pleroma/-/jobs/84828/artifacts/download
|
||||||
|
SOURCE_SUM=74032e08b6f89321eb5545ff77fb0b1f142cba49c691d69316963d296d16b727
|
||||||
|
SOURCE_SUM_PRG=sha256sum
|
||||||
|
SOURCE_FORMAT=zip
|
||||||
|
SOURCE_IN_SUBDIR=true
|
||||||
|
SOURCE_FILENAME=pleroma-v1.1.7-arm64.zip
|
|
@ -1,73 +0,0 @@
|
||||||
# Pleroma instance configuration
|
|
||||||
|
|
||||||
# NOTE: This file should not be committed to a repo or otherwise made public
|
|
||||||
# without removing sensitive information.
|
|
||||||
|
|
||||||
use Mix.Config
|
|
||||||
|
|
||||||
config :pleroma, Pleroma.Web.Endpoint,
|
|
||||||
url: [host: "__DOMAIN__", scheme: "https", port: 443],
|
|
||||||
secret_key_base: "__KEY__",
|
|
||||||
http: [ip: {127, 0, 0, 1}, port: __PORT__]
|
|
||||||
|
|
||||||
config :pleroma, :instance,
|
|
||||||
name: "__INSTANCE_NAME__",
|
|
||||||
email: "__ADMIN_EMAIL__",
|
|
||||||
limit: 5000,
|
|
||||||
registrations_open: __REG__,
|
|
||||||
dedupe_media: false
|
|
||||||
|
|
||||||
config :pleroma, :media_proxy,
|
|
||||||
enabled: __MEDIA_CACHE__,
|
|
||||||
redirect_on_failure: true
|
|
||||||
#base_url: "https://cache.pleroma.social"
|
|
||||||
|
|
||||||
config :pleroma, Pleroma.Repo,
|
|
||||||
adapter: Ecto.Adapters.Postgres,
|
|
||||||
username: "__DB_NAME__",
|
|
||||||
password: "__DB_PWD__",
|
|
||||||
database: "__DB_NAME__",
|
|
||||||
hostname: "localhost",
|
|
||||||
pool_size: 10
|
|
||||||
|
|
||||||
# Enable Strict-Transport-Security once SSL is working:
|
|
||||||
# config :pleroma, :http_security,
|
|
||||||
# sts: true
|
|
||||||
|
|
||||||
# Configure S3 support if desired.
|
|
||||||
# The public S3 endpoint is different depending on region and provider,
|
|
||||||
# consult your S3 provider's documentation for details on what to use.
|
|
||||||
#
|
|
||||||
# config :pleroma, Pleroma.Uploaders.S3,
|
|
||||||
# bucket: "some-bucket",
|
|
||||||
# public_endpoint: "https://s3.amazonaws.com"
|
|
||||||
#
|
|
||||||
# Configure S3 credentials:
|
|
||||||
# config :ex_aws, :s3,
|
|
||||||
# access_key_id: "xxxxxxxxxxxxx",
|
|
||||||
# secret_access_key: "yyyyyyyyyyyy",
|
|
||||||
# region: "us-east-1",
|
|
||||||
# scheme: "https://"
|
|
||||||
#
|
|
||||||
# For using third-party S3 clones like wasabi, also do:
|
|
||||||
# config :ex_aws, :s3,
|
|
||||||
# host: "s3.wasabisys.com"
|
|
||||||
|
|
||||||
|
|
||||||
# Configure Openstack Swift support if desired.
|
|
||||||
#
|
|
||||||
# Many openstack deployments are different, so config is left very open with
|
|
||||||
# no assumptions made on which provider you're using. This should allow very
|
|
||||||
# wide support without needing separate handlers for OVH, Rackspace, etc.
|
|
||||||
#
|
|
||||||
# config :pleroma, Pleroma.Uploaders.Swift,
|
|
||||||
# container: "some-container",
|
|
||||||
# username: "api-username-yyyy",
|
|
||||||
# password: "api-key-xxxx",
|
|
||||||
# tenant_id: "<openstack-project/tenant-id>",
|
|
||||||
# auth_url: "https://keystone-endpoint.provider.com",
|
|
||||||
# storage_url: "https://swift-endpoint.prodider.com/v1/AUTH_<tenant>/<container>",
|
|
||||||
# object_url: "https://cdn-endpoint.provider.com/<container>"
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,23 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=__APP__ social network
|
Description=__APP__ social network
|
||||||
After=network.target postgresql.service
|
After=network.target postgresql.service nginx.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecReload=/bin/kill $MAINPID
|
|
||||||
KillMode=process
|
KillMode=process
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|
||||||
; Name of the user that runs the Pleroma service.
|
; Name of the user that runs the Pleroma service.
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
; Declares that Pleroma runs in production mode.
|
|
||||||
Environment="MIX_ENV=prod"
|
|
||||||
|
|
||||||
; Make sure that all paths fit your installation.
|
; Make sure that all paths fit your installation.
|
||||||
; Path to the home directory of the user running the Pleroma service.
|
; Path to the home directory of the user running the Pleroma service.
|
||||||
Environment="HOME=__FINALPATH__"
|
Environment="HOME=__FINALPATH__/__APP__"
|
||||||
; Path to the folder containing the Pleroma installation.
|
; Path to the folder containing the Pleroma installation.
|
||||||
WorkingDirectory=__FINALPATH__/__APP__
|
WorkingDirectory=__FINALPATH__/__APP__
|
||||||
; Path to the Mix binary.
|
; Path to the Pleroma binary.
|
||||||
ExecStart=/usr/bin/mix phx.server
|
ExecStart=__FINALPATH__/__APP__/bin/pleroma start
|
||||||
StandardOutput=syslog
|
ExecStop=__FINALPATH__/__APP__/bin/pleroma stop
|
||||||
StandardError=syslog
|
|
||||||
|
|
||||||
; Some security directives.
|
; Some security directives.
|
||||||
; Use private /tmp and /var/tmp folders inside a new file system namespace, which are discarded after the process stops.
|
; Use private /tmp and /var/tmp folders inside a new file system namespace, which are discarded after the process stops.
|
||||||
|
|
6
conf/x86-64.src
Normal file
6
conf/x86-64.src
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
SOURCE_URL=https://git.pleroma.social/pleroma/pleroma/-/jobs/84824/artifacts/download
|
||||||
|
SOURCE_SUM=6cd69e80894af966bb88505dae572e197c96da02ba980357a606bcc948a78e36
|
||||||
|
SOURCE_SUM_PRG=sha256sum
|
||||||
|
SOURCE_FORMAT=zip
|
||||||
|
SOURCE_IN_SUBDIR=true
|
||||||
|
SOURCE_FILENAME=pleroma-v1.1.7-x86-64.zip
|
|
@ -6,7 +6,7 @@
|
||||||
"en": "Pleroma is an OStatus-compatible social networking server written in Elixir, compatible with GNU Social and Mastodon",
|
"en": "Pleroma is an OStatus-compatible social networking server written in Elixir, compatible with GNU Social and Mastodon",
|
||||||
"fr": "Pleroma est un réseau social écrit en Elixir, compatible avec OStatus, GNU Social et Mastodon"
|
"fr": "Pleroma est un réseau social écrit en Elixir, compatible avec OStatus, GNU Social et Mastodon"
|
||||||
},
|
},
|
||||||
"version": "0.9.99999~ynh1",
|
"version": "1.1.7~ynh1",
|
||||||
"url": "https://git.pleroma.social/pleroma/pleroma",
|
"url": "https://git.pleroma.social/pleroma/pleroma",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"maintainer": [
|
"maintainer": [
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 3.5"
|
"yunohost": ">= 3.5"
|
||||||
},
|
},
|
||||||
"multi_instance": true,
|
"multi_instance": false,
|
||||||
"services": [
|
"services": [
|
||||||
"nginx"
|
"nginx"
|
||||||
],
|
],
|
||||||
|
@ -69,8 +69,8 @@
|
||||||
"en": "Choose a name for your Pleroma instance",
|
"en": "Choose a name for your Pleroma instance",
|
||||||
"fr": "Choisissez un nom pour votre instance Pleroma"
|
"fr": "Choisissez un nom pour votre instance Pleroma"
|
||||||
},
|
},
|
||||||
"example": "My Pleroma",
|
"example": "My_Pleroma",
|
||||||
"default": "My Pleroma"
|
"default": "My_Pleroma"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "registration",
|
"name": "registration",
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# dependencies used by the app
|
# dependencies used by the app
|
||||||
pkg_dependencies="git build-essential postgresql postgresql-contrib openssl ssh sudo"
|
pkg_dependencies="curl unzip libncurses5 postgresql postgresql-contrib"
|
||||||
extra_pkg_dependencies="elixir erlang-dev erlang-tools erlang-parsetools erlang-eldap erlang-xmerl"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
|
|
|
@ -6,12 +6,14 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Managing script failure..."
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
|
@ -29,6 +31,7 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
|
|
||||||
cache=$(ynh_app_setting_get --app=$app --key=cache)
|
cache=$(ynh_app_setting_get --app=$app --key=cache)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -38,7 +41,7 @@ cache=$(ynh_app_setting_get --app=$app --key=cache)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Stopping a systemd service..."
|
ynh_print_info --message="Stopping a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="stop"
|
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped $app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
|
@ -69,11 +72,11 @@ ynh_psql_dump_db --database="$db_name" > db.sql
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC BACKUP
|
# SPECIFIC BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP LOGROTATE
|
# BACKUP CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Backing up logrotate configuration..."
|
ynh_print_info --message="Backing up configuration file..."
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
ynh_backup --src_path="/etc/$app/config.exs"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP SYSTEMD
|
# BACKUP SYSTEMD
|
||||||
|
@ -87,7 +90,10 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Starting a systemd service..."
|
ynh_print_info --message="Starting a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start"
|
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started $app"
|
||||||
|
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||||
|
sleep 60
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -34,6 +34,23 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
#db_user=$db_name
|
#db_user=$db_name
|
||||||
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Backing up the app before changing its url (may take a while)..."
|
||||||
|
|
||||||
|
# Backup the current version of the app
|
||||||
|
ynh_backup_before_upgrade
|
||||||
|
ynh_clean_setup () {
|
||||||
|
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||||
|
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
|
|
||||||
|
# restore it if the upgrade fails
|
||||||
|
ynh_restore_upgradebackup
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -53,11 +70,11 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Stopping a systemd service..."
|
ynh_print_info --message="Stopping a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="stop"
|
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped $app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
|
@ -111,7 +128,10 @@ ynh_store_file_checksum --file="$final_path/$app/config/prod.secret.exs"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Starting a systemd service..."
|
ynh_print_info --message="Starting a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Running Pleroma.Web.Endpoint"
|
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started $app"
|
||||||
|
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||||
|
sleep 60
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
|
|
165
scripts/install
165
scripts/install
|
@ -7,12 +7,13 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source ynh_add_extra_apt_repos__3
|
source ynh_detect_arch__2
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Managing script failure..."
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
|
@ -23,6 +24,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Retrieving arguments from the manifest..."
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url="/"
|
path_url="/"
|
||||||
|
@ -34,11 +36,11 @@ registration=$YNH_APP_ARG_REGISTRATION
|
||||||
cache=$YNH_APP_ARG_CACHE
|
cache=$YNH_APP_ARG_CACHE
|
||||||
size=$YNH_APP_ARG_SIZE
|
size=$YNH_APP_ARG_SIZE
|
||||||
random_key=$(ynh_string_random --length=64)
|
random_key=$(ynh_string_random --length=64)
|
||||||
|
signing_salt=$(ynh_string_random --length=8)
|
||||||
admin_email=$(ynh_user_get_info --username=$admin --key="mail")
|
admin_email=$(ynh_user_get_info --username=$admin --key="mail")
|
||||||
|
|
||||||
## Bypass package_checker name not compatible with pleroma
|
## Bypass package_checker name not compatible with pleroma
|
||||||
if [ "$admin" = "package_checker" ]
|
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||||
then
|
|
||||||
admin="test"
|
admin="test"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -64,12 +66,13 @@ 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=path --value=$path_url
|
||||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||||
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
||||||
ynh_app_setting_set --app=$app --key=name --value="$name"
|
ynh_app_setting_set --app=$app --key=name --value=$name
|
||||||
ynh_app_setting_set --app=$app --key=registration --value="$registration"
|
ynh_app_setting_set --app=$app --key=registration --value=$registration
|
||||||
ynh_app_setting_set --app=$app --key=cache --value="$cache"
|
ynh_app_setting_set --app=$app --key=cache --value=$cache
|
||||||
ynh_app_setting_set --app=$app --key=size --value="$size"
|
ynh_app_setting_set --app=$app --key=size --value=$size
|
||||||
ynh_app_setting_set --app=$app --key=admin_email --value="$admin_email"
|
ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email
|
||||||
ynh_app_setting_set --app=$app --key=random_key --value="$random_key"
|
ynh_app_setting_set --app=$app --key=random_key --value=$random_key
|
||||||
|
ynh_app_setting_set --app=$app --key=signing_salt --value=$signing_salt
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
|
@ -78,7 +81,7 @@ ynh_app_setting_set --app=$app --key=random_key --value="$random_key"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Configuring firewall..."
|
ynh_print_info --message="Configuring firewall..."
|
||||||
|
|
||||||
# Find a free port
|
# Find an available port
|
||||||
port=$(ynh_find_port --port=8095)
|
port=$(ynh_find_port --port=8095)
|
||||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||||
|
|
||||||
|
@ -89,9 +92,6 @@ ynh_print_info --message="Installing dependencies..."
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
lsb_name="$(lsb_release --codename --short)"
|
|
||||||
ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.com/debian $lsb_name contrib" --package="$extra_pkg_dependencies" --key='https://packages.erlang-solutions.com/debian/erlang_solutions.asc'
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A POSTGRESQL DATABASE
|
# CREATE A POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -116,7 +116,8 @@ ynh_print_info --message="Setting up source files..."
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir="$final_path/$app"
|
architecture=$(ynh_detect_arch)
|
||||||
|
ynh_setup_source --dest_dir="$final_path/$app" --source_id=$architecture
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -140,66 +141,40 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Configuring system user ..."
|
ynh_print_info --message="Configuring system user..."
|
||||||
|
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
|
#=================================================
|
||||||
|
# CREATE THE DATA DIRECTORY
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Create the data directory..."
|
||||||
|
|
||||||
|
# Define app's data directory
|
||||||
|
datadir="/home/yunohost.app/${app}"
|
||||||
|
|
||||||
|
# Create app folders
|
||||||
|
mkdir -p "$datadir/"
|
||||||
|
mkdir -p "$datadir/uploads/"
|
||||||
|
mkdir -p "$datadir/static/"
|
||||||
|
mkdir -p "$datadir/static/emoji/"
|
||||||
|
|
||||||
|
# Give permission to the datadir
|
||||||
|
chown -R "$app":"$app" "$datadir"
|
||||||
|
|
||||||
|
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY A CONFIG FILE
|
# MODIFY A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
cp -f ../conf/generated_config.exs "$final_path/$app/config/prod.secret.exs"
|
mkdir -p /etc/$app
|
||||||
|
chown -R $app /etc/$app
|
||||||
|
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/$app/config/prod.secret.exs"
|
config="/etc/$app/config.exs"
|
||||||
ynh_replace_string --match_string="__KEY__" --replace_string="$random_key" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
ynh_replace_string --match_string="__INSTANCE_NAME__" --replace_string="$name" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
ynh_replace_string --match_string="__ADMIN_EMAIL__" --replace_string="$admin_email" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
|
|
||||||
if [ $cache -eq 1 ]
|
|
||||||
then
|
|
||||||
ynh_replace_string --match_string="__MEDIA_CACHE__" --replace_string="true" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
else
|
|
||||||
ynh_replace_string --match_string="__MEDIA_CACHE__" --replace_string="false" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set registrations open/closed
|
|
||||||
if [ $registration -eq 1 ]
|
|
||||||
then
|
|
||||||
ynh_replace_string --match_string="__REG__" --replace_string="true" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
else
|
|
||||||
ynh_replace_string --match_string="__REG__" --replace_string="false" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MAKE SETUP
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Give permission to the final_path
|
|
||||||
chown -R "$app":"$app" "$final_path"
|
|
||||||
|
|
||||||
pushd $final_path/$app
|
|
||||||
# App setup and db migration
|
|
||||||
sudo -u "$app" MIX_ENV=prod mix local.hex --force
|
|
||||||
sudo -u "$app" MIX_ENV=prod mix local.rebar --force
|
|
||||||
sudo -u "$app" MIX_ENV=prod mix deps.get
|
|
||||||
sudo -u "$app" MIX_ENV=prod mix ecto.migrate
|
|
||||||
|
|
||||||
# Add user
|
|
||||||
sudo -u "$app" MIX_ENV=prod mix pleroma.user new "$admin" "$admin_email" --password "$password" --moderator --admin -y
|
|
||||||
|
|
||||||
#Generate key pair
|
|
||||||
sudo -u "$app" MIX_ENV=prod mix web_push.gen.keypair >> "config/prod.secret.exs"
|
|
||||||
ynh_replace_string --match_string="administrator@example.com" --replace_string="$admin_email" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
|
|
||||||
#Create uploads dir
|
|
||||||
mkdir uploads
|
|
||||||
popd
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
|
@ -209,44 +184,68 @@ ynh_print_info --message="Configuring a systemd service..."
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
ynh_add_systemd_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MAKE SETUP
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Give permission to the final_path
|
||||||
|
chown -R "$app":"$app" "$final_path"
|
||||||
|
|
||||||
|
pushd $final_path/$app
|
||||||
|
#Workaround for static-dir error
|
||||||
|
ynh_replace_string --match_string="_dir" --replace_string="" --target_file="/var/www/pleroma/pleroma/releases/1.1.7/releases.exs"
|
||||||
|
|
||||||
|
#Generate instance
|
||||||
|
su "$app" -s $SHELL -lc "$final_path/$app/bin/pleroma_ctl instance gen --force \
|
||||||
|
--output $config \
|
||||||
|
--output-psql /tmp/setup_db.psql \
|
||||||
|
--domain $domain \
|
||||||
|
--instance-name \"$name\" \
|
||||||
|
--admin-email $admin_email \
|
||||||
|
--notify-email $admin_email \
|
||||||
|
--dbhost localhost \
|
||||||
|
--dbname $db_name \
|
||||||
|
--dbuser $db_user \
|
||||||
|
--dbpass $db_pwd \
|
||||||
|
--rum N \
|
||||||
|
--indexable Y \
|
||||||
|
--uploads-dir $datadir/uploads \
|
||||||
|
--static-dir $datadir/static \
|
||||||
|
--listen-ip 127.0.0.1 \
|
||||||
|
--listen-port $port"
|
||||||
|
|
||||||
|
su "$app" -s $SHELL -lc "$final_path/$app/bin/pleroma_ctl migrate"
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started $app"
|
||||||
|
sleep 60
|
||||||
|
|
||||||
|
# Add user
|
||||||
|
su pleroma -s $SHELL -lc "$final_path/$app/bin/pleroma_ctl user new $admin $admin_email --password $password --moderator --admin -y"
|
||||||
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE THE CONFIG FILE CHECKSUM
|
# STORE THE CONFIG FILE CHECKSUM
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
# Calculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum --file="$final_path/$app/config/prod.secret.exs"
|
ynh_store_file_checksum --file="$config"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# SECURE FILES AND DIRECTORIES
|
# SECURE FILES AND DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Securing files and directories..."
|
||||||
|
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
chown -R "$app":"$app" "$final_path"
|
chown -R "$app":"$app" "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Configuring log rotation..."
|
ynh_print_info --message="Integrating service in YunoHost..."
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
yunohost service add $app --description "$app daemon for Pleroma" --log_type "systemd"
|
||||||
ynh_use_logrotate
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#yunohost service add $app --log "/var/log/$app/APP.log"
|
|
||||||
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
|
|
||||||
yunohost service add $app --description "$app daemon for Pleroma" --log "/var/log/$app/$app.log"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# START SYSTEMD SERVICE
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Starting a systemd service..."
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Running Pleroma.Web.Endpoint"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
|
|
|
@ -21,21 +21,29 @@ port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
cache=$(ynh_app_setting_get --app=$app --key=cache)
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SERVICE FROM ADMIN PANEL
|
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Removing service integration in YunoHost..."
|
||||||
|
|
||||||
# Remove a service from the admin panel, added by `yunohost service add`
|
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
|
||||||
if yunohost service status $app >/dev/null 2>&1
|
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||||
then
|
then
|
||||||
ynh_print_info --message="Removing $app service..."
|
ynh_print_info --message="Removing $app service..."
|
||||||
yunohost service remove $app
|
yunohost service remove $app
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STOP ALL PLEROMA SERVICES
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Stopping all pleroma services..."
|
||||||
|
|
||||||
|
pkill -u $app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP AND REMOVE SERVICE
|
# STOP AND REMOVE SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -77,18 +85,10 @@ ynh_print_info --message="Removing nginx web server configuration..."
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
ynh_secure_remove --file="/etc/nginx/conf.d/$app-cache.conf"
|
ynh_secure_remove --file="/etc/nginx/conf.d/$app-cache.conf"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE LOGROTATE CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Removing logrotate configuration..."
|
|
||||||
|
|
||||||
# Remove the app-specific logrotate config
|
|
||||||
ynh_remove_logrotate
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CLOSE A PORT
|
# CLOSE A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Closing ports"
|
ynh_print_info --message="Closing a port"
|
||||||
|
|
||||||
if yunohost firewall list | grep -q "\- $port$"
|
if yunohost firewall list | grep -q "\- $port$"
|
||||||
then
|
then
|
||||||
|
@ -99,14 +99,14 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC REMOVE
|
# SPECIFIC REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE CRON FILE
|
# REMOVE DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Remove a directory securely
|
# Remove the config directory securely
|
||||||
ynh_secure_remove "/etc/$app/"
|
ynh_secure_remove "/etc/$app/"
|
||||||
|
|
||||||
# Remove the log files
|
# Remove the data directory securely
|
||||||
ynh_secure_remove "/var/log/$app/"
|
ynh_secure_remove "$datadir/"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
|
|
@ -6,13 +6,14 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source ../settings/scripts/ynh_add_extra_apt_repos__3
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Managing script failure..."
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
|
@ -35,6 +36,7 @@ db_user=$db_name
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
cache=$(ynh_app_setting_get --app=$app --key=cache)
|
cache=$(ynh_app_setting_get --app=$app --key=cache)
|
||||||
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
|
@ -76,12 +78,36 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE USER RIGHTS
|
# RESTORE USER RIGHTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Restoring user rights..."
|
||||||
|
|
||||||
# Restore permissions on app files
|
# Restore permissions on app files
|
||||||
chown -R "$app":"$app" "$final_path"
|
chown -R "$app":"$app" "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# SPECIFIC RESTORATION
|
||||||
|
#=================================================
|
||||||
|
# RECREATE THE DATA DIRECTORY
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Recreate the data directory..."
|
||||||
|
|
||||||
|
# Create app folders
|
||||||
|
mkdir -p "$datadir/"
|
||||||
|
mkdir -p "$datadir/uploads/"
|
||||||
|
mkdir -p "$datadir/static/"
|
||||||
|
mkdir -p "$datadir/static/emoji/"
|
||||||
|
|
||||||
|
# Give permission to the datadir
|
||||||
|
chown -R "$app":"$app" "$datadir"
|
||||||
|
|
||||||
|
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE CONFIG FILE
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Restoring the config file..."
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="/etc/$app/config.exs"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -90,9 +116,6 @@ ynh_print_info --message="Reinstalling dependencies..."
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
lsb_name="$(lsb_release --codename --short)"
|
|
||||||
ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.com/debian $lsb_name contrib" --package="$extra_pkg_dependencies" --key='https://packages.erlang-solutions.com/debian/erlang_solutions.asc'
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE POSTGRESQL DATABASE
|
# RESTORE THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -115,23 +138,21 @@ ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||||
systemctl enable $app.service
|
systemctl enable $app.service
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Integrating service in YunoHost..."
|
||||||
|
|
||||||
yunohost service add $app --description "$app daemon for Pleroma" --log "/var/log/$app/$app.log"
|
yunohost service add $app --description "$app daemon for Pleroma" --log_type "systemd"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Starting a systemd service..."
|
ynh_print_info --message="Starting a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Running Pleroma.Web.Endpoint"
|
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started $app"
|
||||||
|
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||||
#=================================================
|
sleep 60
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
fi
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
|
127
scripts/upgrade
127
scripts/upgrade
|
@ -7,7 +7,8 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source ynh_add_extra_apt_repos__3
|
source ynh_package_version
|
||||||
|
source ynh_detect_arch__2
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -27,6 +28,7 @@ admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
|
||||||
random_key=$(ynh_app_setting_get --app=$app --key=random_key)
|
random_key=$(ynh_app_setting_get --app=$app --key=random_key)
|
||||||
name=$(ynh_app_setting_get --app=$app --key=name)
|
name=$(ynh_app_setting_get --app=$app --key=name)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
|
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||||
cache=$(ynh_app_setting_get --app=$app --key=cache)
|
cache=$(ynh_app_setting_get --app=$app --key=cache)
|
||||||
size=$(ynh_app_setting_get --app=$app --key=size)
|
size=$(ynh_app_setting_get --app=$app --key=size)
|
||||||
|
@ -89,6 +91,17 @@ fi
|
||||||
ynh_secure_remove --file="/etc/apt/sources.list.d/erlang-solutions.list"
|
ynh_secure_remove --file="/etc/apt/sources.list.d/erlang-solutions.list"
|
||||||
apt-key del A14F4FCA
|
apt-key del A14F4FCA
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK VERSION NUMBER
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||||
|
sleep 60
|
||||||
|
fi
|
||||||
|
abort_if_up_to_date
|
||||||
|
# previous function is what defines 'version', more precisely the 'previous version'
|
||||||
|
previous_version="${version}"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -97,6 +110,7 @@ ynh_print_info --message="Backing up the app before upgrading (may take a while)
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
|
read -p "key"
|
||||||
# restore it if the upgrade fails
|
# restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
ynh_restore_upgradebackup
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
|
@ -104,13 +118,6 @@ ynh_clean_setup () {
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK THE PATH
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Normalize the URL path syntax
|
|
||||||
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -118,18 +125,58 @@ path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Stopping a systemd service..."
|
ynh_print_info --message="Stopping a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="stop"
|
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped $app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE TO OTP RELEASE
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Upgrading to OTP release..."
|
||||||
|
|
||||||
|
if ynh_version_gt "1.1.1~ynh1" "${previous_version}" ; then
|
||||||
|
# Define app's data directory
|
||||||
|
datadir="/home/yunohost.app/${app}"
|
||||||
|
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
|
||||||
|
|
||||||
|
# Create app folders
|
||||||
|
mkdir -p "$datadir/"
|
||||||
|
mkdir -p "$datadir/uploads/"
|
||||||
|
mkdir -p "$datadir/static/"
|
||||||
|
mkdir -p "$datadir/static/emoji/"
|
||||||
|
|
||||||
|
# Give permission to the datadir
|
||||||
|
chown -R "$app":"$app" "$datadir"
|
||||||
|
|
||||||
|
rsync -a "$final_path/$app/uploads/" "$datadir/uploads/"
|
||||||
|
if [ -d "$final_path/$app/instance/static/" ]; then
|
||||||
|
rsync -a "$final_path/$app/instance/static/" "$datadir/static/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ls -d $final_path/$app/priv/static/emoji/*/ | xargs -i sh -c 'mv "{}" "$datadir/static/emoji/$(basename {})"'
|
||||||
|
rsync -a "$final_path/$app/priv/static/emoji/" "$datadir/static/emoji/"
|
||||||
|
|
||||||
|
mkdir -p /etc/$app
|
||||||
|
chown -R $app /etc/$app
|
||||||
|
config="/etc/$app/config.exs"
|
||||||
|
mv $final_path/$app/config/prod.secret.exs $config
|
||||||
|
ynh_replace_string --match_string="use Mix.Config" --replace_string="import Config" --target_file="$config"
|
||||||
|
|
||||||
|
ynh_backup_if_checksum_is_different --file="$config"
|
||||||
|
|
||||||
|
rm -r $final_path/$app/*
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Upgrading source files..."
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
ynh_print_info --message="Upgrading source files..."
|
ynh_print_info --message="Upgrading source files..."
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir="$final_path/$app"
|
architecture=$(ynh_detect_arch)
|
||||||
|
ynh_setup_source --dest_dir="$final_path/$app" --source_id=$architecture
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -160,9 +207,6 @@ ynh_print_info --message="Upgrading dependencies..."
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
lsb_name="$(lsb_release --codename --short)"
|
|
||||||
ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.com/debian $lsb_name contrib" --package="$extra_pkg_dependencies" --key='https://packages.erlang-solutions.com/debian/erlang_solutions.asc'
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -176,62 +220,32 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY A CONFIG FILE
|
# MODIFY A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Modifying a config file..."
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different --file="$final_path/$app/config/prod.secret.exs"
|
config="/etc/$app/config.exs"
|
||||||
cp -f ../conf/generated_config.exs "$final_path/$app/config/prod.secret.exs"
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/$app/config/prod.secret.exs"
|
ynh_backup_if_checksum_is_different --file="$config"
|
||||||
ynh_replace_string --match_string="__KEY__" --replace_string="$random_key" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
ynh_replace_string --match_string="__INSTANCE_NAME__" --replace_string="$name" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
ynh_replace_string --match_string="__ADMIN_EMAIL__" --replace_string="$admin_email" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
|
|
||||||
if [ $cache -eq 1 ]
|
|
||||||
then
|
|
||||||
ynh_replace_string --match_string="__MEDIA_CACHE__" --replace_string="true" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
else
|
|
||||||
ynh_replace_string --match_string="__MEDIA_CACHE__" --replace_string="false" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set registrations open/closed
|
|
||||||
if [ $registration -eq 1 ]
|
|
||||||
then
|
|
||||||
ynh_replace_string --match_string="__REG__" --replace_string="true" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
else
|
|
||||||
ynh_replace_string --match_string="__REG__" --replace_string="false" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MAKE UPGRADE
|
# MAKE UPGRADE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Making upgrade..."
|
||||||
|
|
||||||
# Give permission to the final_path
|
# Give permission to the final_path
|
||||||
chown -R "$app":"$app" "$final_path"
|
chown -R "$app":"$app" "$final_path"
|
||||||
|
|
||||||
pushd $final_path/$app
|
pushd $final_path/$app
|
||||||
sudo -u "$app" MIX_ENV=prod mix deps.get
|
su "$app" -s $SHELL -lc "$final_path/$app/bin/pleroma_ctl update"
|
||||||
sudo -u "$app" MIX_ENV=prod mix ecto.migrate
|
su "$app" -s $SHELL -lc "$final_path/$app/bin/pleroma_ctl migrate"
|
||||||
|
|
||||||
#Generate key pair
|
|
||||||
sudo -u "$app" MIX_ENV=prod mix web_push.gen.keypair >> "config/prod.secret.exs"
|
|
||||||
ynh_replace_string --match_string="administrator@example.com" --replace_string="$admin_email" --target_file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE THE CONFIG FILE CHECKSUM
|
# STORE THE CONFIG FILE CHECKSUM
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Storing the config file checksum..."
|
||||||
|
|
||||||
# Recalculate and store the checksum of the file for the next upgrade.
|
# Recalculate and store the checksum of the file for the next upgrade.
|
||||||
ynh_store_file_checksum --file="$final_path/$app/config/prod.secret.exs"
|
ynh_store_file_checksum --file="$config"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP LOGROTATE
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Upgrading logrotate configuration..."
|
|
||||||
|
|
||||||
# Use logrotate to manage app-specific logfile(s)
|
|
||||||
ynh_use_logrotate --non-append
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
|
@ -246,6 +260,7 @@ ynh_add_systemd_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# SECURE FILES AND DIRECTORIES
|
# SECURE FILES AND DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Securing files and directories..."
|
||||||
|
|
||||||
# Set permissions on app files
|
# Set permissions on app files
|
||||||
chown -R "$app":"$app" "$final_path"
|
chown -R "$app":"$app" "$final_path"
|
||||||
|
@ -263,12 +278,14 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Starting a systemd service..."
|
ynh_print_info --message="Starting a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Running Pleroma.Web.Endpoint"
|
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Started $app"
|
||||||
sleep 10
|
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||||
|
sleep 60
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
|
|
|
@ -1,294 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Pin a repository.
|
|
||||||
#
|
|
||||||
# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append]
|
|
||||||
# | arg: -p, --package - Packages concerned by the pin. Or all, *.
|
|
||||||
# | arg: -i, --pin - Filter for the pin.
|
|
||||||
# | arg: -p, --priority - Priority for the pin
|
|
||||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
|
||||||
# | arg: -a, --append - Do not overwrite existing files.
|
|
||||||
#
|
|
||||||
# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning.
|
|
||||||
#
|
|
||||||
ynh_pin_repo () {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=pirna
|
|
||||||
declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append )
|
|
||||||
local package
|
|
||||||
local pin
|
|
||||||
local priority
|
|
||||||
local name
|
|
||||||
local append
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
package="${package:-*}"
|
|
||||||
priority=${priority:-50}
|
|
||||||
name="${name:-$app}"
|
|
||||||
append=${append:-0}
|
|
||||||
|
|
||||||
if [ $append -eq 1 ]
|
|
||||||
then
|
|
||||||
append="tee -a"
|
|
||||||
else
|
|
||||||
append="tee"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "/etc/apt/preferences.d"
|
|
||||||
echo "Package: $package
|
|
||||||
Pin: $pin
|
|
||||||
Pin-Priority: $priority" \
|
|
||||||
| $append "/etc/apt/preferences.d/$name"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Add a repository.
|
|
||||||
#
|
|
||||||
# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append]
|
|
||||||
# | arg: -u, --uri - Uri of the repository.
|
|
||||||
# | arg: -s, --suite - Suite of the repository.
|
|
||||||
# | arg: -c, --component - Component of the repository.
|
|
||||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
|
||||||
# | arg: -a, --append - Do not overwrite existing files.
|
|
||||||
#
|
|
||||||
# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable
|
|
||||||
# uri suite component
|
|
||||||
# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable
|
|
||||||
#
|
|
||||||
ynh_add_repo () {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=uscna
|
|
||||||
declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append )
|
|
||||||
local uri
|
|
||||||
local suite
|
|
||||||
local component
|
|
||||||
local name
|
|
||||||
local append
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
name="${name:-$app}"
|
|
||||||
append=${append:-0}
|
|
||||||
|
|
||||||
if [ $append -eq 1 ]
|
|
||||||
then
|
|
||||||
append="tee -a"
|
|
||||||
else
|
|
||||||
append="tee"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "/etc/apt/sources.list.d"
|
|
||||||
# Add the new repo in sources.list.d
|
|
||||||
echo "deb $uri $suite $component" \
|
|
||||||
| $append "/etc/apt/sources.list.d/$name.list"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Add an extra repository correctly, pin it and get the key.
|
|
||||||
#
|
|
||||||
# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append]
|
|
||||||
# | arg: -r, --repo - Complete url of the extra repository.
|
|
||||||
# | arg: -k, --key - url to get the public key.
|
|
||||||
# | arg: -p, --priority - Priority for the pin
|
|
||||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
|
||||||
# | arg: -a, --append - Do not overwrite existing files.
|
|
||||||
ynh_install_extra_repo () {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=rkpna
|
|
||||||
declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append )
|
|
||||||
local repo
|
|
||||||
local key
|
|
||||||
local priority
|
|
||||||
local name
|
|
||||||
local append
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
name="${name:-$app}"
|
|
||||||
append=${append:-0}
|
|
||||||
key=${key:-0}
|
|
||||||
priority=${priority:-}
|
|
||||||
|
|
||||||
if [ $append -eq 1 ]
|
|
||||||
then
|
|
||||||
append="--append"
|
|
||||||
wget_append="tee -a"
|
|
||||||
else
|
|
||||||
append=""
|
|
||||||
wget_append="tee"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Split the repository into uri, suite and components.
|
|
||||||
# Remove "deb " at the beginning of the repo.
|
|
||||||
repo="${repo#deb }"
|
|
||||||
|
|
||||||
# Get the uri
|
|
||||||
local uri="$(echo "$repo" | awk '{ print $1 }')"
|
|
||||||
|
|
||||||
# Get the suite
|
|
||||||
local suite="$(echo "$repo" | awk '{ print $2 }')"
|
|
||||||
|
|
||||||
# Get the components
|
|
||||||
local component="${repo##$uri $suite }"
|
|
||||||
|
|
||||||
# Add the repository into sources.list.d
|
|
||||||
ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append
|
|
||||||
|
|
||||||
# Pin the new repo with the default priority, so it won't be used for upgrades.
|
|
||||||
# Build $pin from the uri without http and any sub path
|
|
||||||
local pin="${uri#*://}"
|
|
||||||
pin="${pin%%/*}"
|
|
||||||
# Set a priority only if asked
|
|
||||||
if [ -n "$priority" ]
|
|
||||||
then
|
|
||||||
priority="--priority=$priority"
|
|
||||||
fi
|
|
||||||
ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append
|
|
||||||
|
|
||||||
# Get the public key for the repo
|
|
||||||
if [ -n "$key" ]
|
|
||||||
then
|
|
||||||
mkdir -p "/etc/apt/trusted.gpg.d"
|
|
||||||
wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Update the list of package with the new repo
|
|
||||||
ynh_package_update
|
|
||||||
}
|
|
||||||
|
|
||||||
# Remove an extra repository and the assiociated configuration.
|
|
||||||
#
|
|
||||||
# usage: ynh_remove_extra_repo [--name=name]
|
|
||||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
|
||||||
ynh_remove_extra_repo () {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=n
|
|
||||||
declare -Ar args_array=( [n]=name= )
|
|
||||||
local name
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
name="${name:-$app}"
|
|
||||||
|
|
||||||
ynh_secure_remove "/etc/apt/sources.list.d/$name.list"
|
|
||||||
ynh_secure_remove "/etc/apt/preferences.d/$name"
|
|
||||||
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg"
|
|
||||||
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc"
|
|
||||||
|
|
||||||
# Update the list of package to exclude the old repo
|
|
||||||
ynh_package_update
|
|
||||||
}
|
|
||||||
|
|
||||||
# Install packages from an extra repository properly.
|
|
||||||
#
|
|
||||||
# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name]
|
|
||||||
# | arg: -r, --repo - Complete url of the extra repository.
|
|
||||||
# | arg: -p, --package - The packages to install from this extra repository
|
|
||||||
# | arg: -k, --key - url to get the public key.
|
|
||||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
|
||||||
ynh_install_extra_app_dependencies () {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=rpkn
|
|
||||||
declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= )
|
|
||||||
local repo
|
|
||||||
local package
|
|
||||||
local key
|
|
||||||
local name
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
name="${name:-$app}"
|
|
||||||
key=${key:-0}
|
|
||||||
|
|
||||||
# Set a key only if asked
|
|
||||||
if [ -n "$key" ]
|
|
||||||
then
|
|
||||||
key="--key=$key"
|
|
||||||
fi
|
|
||||||
# Add an extra repository for those packages
|
|
||||||
ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name
|
|
||||||
|
|
||||||
# Install requested dependencies from this extra repository.
|
|
||||||
ynh_add_app_dependencies --package="$package"
|
|
||||||
|
|
||||||
# Remove this extra repository after packages are installed
|
|
||||||
ynh_remove_extra_repo --name=$app
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies
|
|
||||||
|
|
||||||
# Define and install dependencies with a equivs control file
|
|
||||||
# This helper can/should only be called once per app
|
|
||||||
#
|
|
||||||
# usage: ynh_install_app_dependencies dep [dep [...]]
|
|
||||||
# | arg: dep - the package name to install in dependence
|
|
||||||
# You can give a choice between some package with this syntax : "dep1|dep2"
|
|
||||||
# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5"
|
|
||||||
# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5)
|
|
||||||
#
|
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
|
||||||
ynh_install_app_dependencies () {
|
|
||||||
local dependencies=$@
|
|
||||||
dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')"
|
|
||||||
dependencies=${dependencies//|/ | }
|
|
||||||
local manifest_path="../manifest.json"
|
|
||||||
if [ ! -e "$manifest_path" ]; then
|
|
||||||
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
|
||||||
fi
|
|
||||||
|
|
||||||
local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file.
|
|
||||||
if [ ${#version} -eq 0 ]; then
|
|
||||||
version="1.0"
|
|
||||||
fi
|
|
||||||
local dep_app=${app//_/-} # Replace all '_' by '-'
|
|
||||||
|
|
||||||
# Handle specific versions
|
|
||||||
if [[ "$dependencies" =~ [\<=\>] ]]
|
|
||||||
then
|
|
||||||
# Replace version specifications by relationships syntax
|
|
||||||
# https://www.debian.org/doc/debian-policy/ch-relationships.html
|
|
||||||
# Sed clarification
|
|
||||||
# [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice.
|
|
||||||
# [\<=\>] matches < = or >
|
|
||||||
# \+ matches one or more occurence of the previous characters, for >= or >>.
|
|
||||||
# [^,]\+ matches all characters except ','
|
|
||||||
# Ex: package>=1.0 will be replaced by package (>= 1.0)
|
|
||||||
dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build
|
|
||||||
Section: misc
|
|
||||||
Priority: optional
|
|
||||||
Package: ${dep_app}-ynh-deps
|
|
||||||
Version: ${version}
|
|
||||||
Depends: ${dependencies}
|
|
||||||
Architecture: all
|
|
||||||
Description: Fake package for $app (YunoHost app) dependencies
|
|
||||||
This meta-package is only responsible of installing its dependencies.
|
|
||||||
EOF
|
|
||||||
ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \
|
|
||||||
|| ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies
|
|
||||||
rm /tmp/${dep_app}-ynh-deps.control
|
|
||||||
ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies"
|
|
||||||
}
|
|
||||||
|
|
||||||
ynh_add_app_dependencies () {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
local legacy_args=pr
|
|
||||||
declare -Ar args_array=( [p]=package= [r]=replace)
|
|
||||||
local package
|
|
||||||
local replace
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
replace=${replace:-0}
|
|
||||||
|
|
||||||
local current_dependencies=""
|
|
||||||
if [ $replace -eq 0 ]
|
|
||||||
then
|
|
||||||
local dep_app=${app//_/-} # Replace all '_' by '-'
|
|
||||||
if ynh_package_is_installed --package="${dep_app}-ynh-deps"
|
|
||||||
then
|
|
||||||
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) "
|
|
||||||
fi
|
|
||||||
|
|
||||||
current_dependencies=${current_dependencies// | /|}
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_install_app_dependencies "${current_dependencies}${package}"
|
|
||||||
}
|
|
25
scripts/ynh_detect_arch__2
Normal file
25
scripts/ynh_detect_arch__2
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Check the architecture
|
||||||
|
#
|
||||||
|
# example: architecture=$(ynh_detect_arch)
|
||||||
|
#
|
||||||
|
# usage: ynh_detect_arch
|
||||||
|
#
|
||||||
|
# Requires YunoHost version 2.2.4 or higher.
|
||||||
|
|
||||||
|
ynh_detect_arch(){
|
||||||
|
local architecture
|
||||||
|
if [ -n "$(uname -m | grep arm64)" ] || [ -n "$(uname -m | grep aarch64)" ]; then
|
||||||
|
architecture="arm64"
|
||||||
|
elif [ -n "$(uname -m | grep 64)" ]; then
|
||||||
|
architecture="x86-64"
|
||||||
|
elif [ -n "$(uname -m | grep 86)" ]; then
|
||||||
|
architecture="i386"
|
||||||
|
elif [ -n "$(uname -m | grep arm)" ]; then
|
||||||
|
architecture="arm"
|
||||||
|
else
|
||||||
|
architecture="unknown"
|
||||||
|
fi
|
||||||
|
echo $architecture
|
||||||
|
}
|
26
scripts/ynh_package_version
Normal file
26
scripts/ynh_package_version
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
read_json () {
|
||||||
|
sudo python3 -c "import sys, json;print(json.load(open('$1'))['$2'])"
|
||||||
|
}
|
||||||
|
|
||||||
|
read_manifest () {
|
||||||
|
if [ -f '../manifest.json' ] ; then
|
||||||
|
read_json '../manifest.json' "$1"
|
||||||
|
else
|
||||||
|
read_json '../settings/manifest.json' "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
abort_if_up_to_date () {
|
||||||
|
version=$(read_json "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" 'version' 2> /dev/null || echo '20160501-7')
|
||||||
|
last_version=$(read_manifest 'version')
|
||||||
|
if [ "${version}" = "${last_version}" ]; then
|
||||||
|
ynh_print_info "Up-to-date, nothing to do"
|
||||||
|
ynh_die "" 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ynh_version_gt ()
|
||||||
|
{
|
||||||
|
dpkg --compare-versions "$1" gt "$2"
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue