1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pleroma_ynh.git synced 2024-09-03 20:15:59 +02:00
This commit is contained in:
ericgaspar 2021-08-23 08:04:19 +02:00
parent c054c9136c
commit 86fb8190fa
8 changed files with 100 additions and 206 deletions

View file

@ -1,7 +0,0 @@
language: python
before_install:
- git clone https://github.com/YunoHost/package_linter /tmp/package_linter
script:
- /tmp/package_linter/package_linter.py ./

View file

@ -1,17 +1,12 @@
# See here for more informations
# https://github.com/YunoHost/package_check#syntax-check_process-file
# Move this file from check_process.default to check_process when you have filled it.
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
admin="john" (USER)
is_public=1 (PUBLIC|public=1|private=0)
domain="domain.tld"
admin="john"
is_public=1
password="pass"
name="My_Pleroma"
registration=0 (BOOLEAN)
cache=1 (BOOLEAN)
registration=0
cache=1
size="5g"
; Checks
pkg_linter=1
@ -21,21 +16,6 @@
setup_private=1
setup_public=1
upgrade=1
# 0.9.99999
upgrade=1 from_commit=9ec87c36793780f74365d3059d7b9d12885fbfcb
# 1.1.7
# upgrade=1 from_commit=3e88dd59d8e5593fb60a86ab955aafde76abdf2e
# 1.1.8
# upgrade=1 from_commit=0a839da33898b7a58f12a27b5b51799694021353
# 1.1.9
# upgrade=1 from_commit=eedad6977760c31d7fb94ced247b9136824da580
# 2.0.0
upgrade=1 from_commit=0693dd5efd5ab2a06267993cc7106ed2efc26ea2
# 2.0.1~ynh1
# upgrade=1 from_commit=7c3680c82b9c3f2449c6dbb346a5729a18636ac1
# 2.0.1~ynh2
upgrade=1 from_commit=723df4423d80baa31e9717628bc5b5fd50114bc8
# 2.0.2~ynh1
# upgrade=1 from_commit=8f418ba020cee267f76bb781b03a41d384707a5b
# 2.0.2~ynh2
upgrade=1 from_commit=251a08383f59be006803fd12013baa92b03c1ef7
@ -45,33 +25,11 @@
upgrade=1 from_commit=30696599937984e9879da22220253f005e290cd0
backup_restore=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.
# incorrect_path=1
port_already_use=0
change_url=0
;;; Levels
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
Level 5=auto
;;; Options
Email=anmol@datamol.org;yalh@yahoo.com
Notification=yes
;;; Upgrade options
; commit=9ec87c36793780f74365d3059d7b9d12885fbfcb
name=0.9.99999
; commit=3e88dd59d8e5593fb60a86ab955aafde76abdf2e
name=1.1.7
; commit=0a839da33898b7a58f12a27b5b51799694021353
name=1.1.8
; commit=eedad6977760c31d7fb94ced247b9136824da580
name=1.1.9
; commit=0693dd5efd5ab2a06267993cc7106ed2efc26ea2
name=2.0.0
; commit=7c3680c82b9c3f2449c6dbb346a5729a18636ac1
name=2.0.1~ynh1
; commit=723df4423d80baa31e9717628bc5b5fd50114bc8
name=2.0.1~ynh2
; commit=8f418ba020cee267f76bb781b03a41d384707a5b
name=2.0.2~ynh1
; commit=251a08383f59be006803fd12013baa92b03c1ef7
name=2.0.2~ynh2
; commit=06f0005707e77fae566fedbd6e5e37f390df5173

View file

@ -18,7 +18,7 @@
"name": "yalh76"
}],
"requirements": {
"yunohost": ">= 3.5"
"yunohost": ">= 4.2.0"
},
"multi_instance": false,
"services": [
@ -29,37 +29,21 @@
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain name for Pleroma",
"fr": "Choisissez un nom de domaine pour Pleroma"
},
"example": "example.com"
},
{
"name": "admin",
"type": "user",
"ask": {
"en": "Choose an admin user",
"fr": "Choisissez l'administrateur"
},
"example": "johndoe"
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public application?",
"fr": "Est-ce une application publique ?"
},
"default": true
},
{
"name": "password",
"type": "password",
"ask": {
"en": "Set the administrator password",
"fr": "Définissez le mot de passe administrateur"
},
"example": "Choose a password"
},
{
@ -99,7 +83,7 @@
},
"choices": ["2g","5g","10g","20g","40g","80g"],
"default": "5g"
}
}
]
}
}

View file

@ -18,3 +18,27 @@ pkg_dependencies="curl unzip libncurses5 postgresql postgresql-contrib"
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================
# 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
}

View file

@ -7,7 +7,6 @@
#=================================================
source _common.sh
source ynh_detect_arch__2
source /usr/share/yunohost/helpers
#=================================================
@ -64,7 +63,6 @@ ynh_script_progression --message="Storing installation settings..."
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=is_public --value=$is_public
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=cache --value=$cache
@ -78,7 +76,7 @@ ynh_app_setting_set --app=$app --key=signing_salt --value=$signing_salt
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Configuring firewall..."
ynh_script_progression --message="Finding an available port..."
# Find an available port
port=$(ynh_find_port --port=8095)
@ -89,7 +87,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE A POSTGRESQL DATABASE
@ -98,16 +96,23 @@ ynh_script_progression --message="Creating a PostgreSQL database..."
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
db_pwd=$(ynh_string_random --length=30)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_setup_db --db_user=$db_name --db_name=$db_name
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database=$db_name
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS citext;" --database=$db_name
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";" --database=$db_name
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -118,10 +123,14 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
architecture=$(ynh_detect_arch)
ynh_setup_source --dest_dir="$final_path/$app" --source_id=$architecture
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring nginx web server..."
ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated nginx config
ynh_add_nginx_config
@ -138,14 +147,6 @@ then
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# SPECIFIC SETUP
#=================================================
@ -163,7 +164,7 @@ mkdir -p "$datadir/static/"
mkdir -p "$datadir/static/emoji/"
# Give permission to the datadir
chown -R "$app":"$app" "$datadir"
chown -R $app: "$datadir"
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
@ -195,7 +196,7 @@ chown -R "$app":"$app" "$final_path"
pushd $final_path/$app
#Generate instance
su "$app" -s $SHELL -lc "$final_path/$app/bin/pleroma_ctl instance gen --force \
ynh_exec_warn_less su "$app" -s $SHELL -lc "$final_path/$app/bin/pleroma_ctl instance gen --force \
--output $config \
--output-psql /tmp/setup_db.psql \
--domain $domain \
@ -238,39 +239,29 @@ ynh_script_progression --message="Storing the config file checksum..."
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$config"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions to app files
chown -R "$app":"$app" "$final_path"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "$app daemon for Pleroma" --log_type "systemd"
yunohost service add $app --description "$app daemon for Pleroma" --log_path=systemd
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring SSOwat..."
ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
ynh_permission_update --permission="main" --add="visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -32,7 +32,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=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=psqlpwd)
port=$(ynh_app_setting_get --app=$app --key=port)
cache=$(ynh_app_setting_get --app=$app --key=cache)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
@ -52,7 +52,7 @@ test ! -d $final_path \
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the nginx configuration..."
ynh_script_progression --message="Restoring the NGINX configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
@ -61,13 +61,6 @@ then
ynh_restore_file --origin_path="/etc/nginx/conf.d/$app-cache.conf"
fi
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
@ -77,12 +70,15 @@ ynh_script_progression --message="Recreating the dedicated system user..."
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE USER RIGHTS
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring user rights..."
ynh_script_progression --message="Restoring the app main directory..."
# Restore permissions on app files
chown -R "$app":"$app" "$final_path"
ynh_restore_file --origin_path="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# SPECIFIC RESTORATION
@ -98,7 +94,7 @@ mkdir -p "$datadir/static/"
mkdir -p "$datadir/static/emoji/"
# Give permission to the datadir
chown -R "$app":"$app" "$datadir"
chown -R $app: "$datadir"
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
@ -115,7 +111,7 @@ ynh_restore_file --origin_path="/etc/$app/config.exs"
ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE POSTGRESQL DATABASE
@ -136,14 +132,14 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service
systemctl enable $app.service --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "$app daemon for Pleroma" --log_type "systemd"
yunohost service add $app --description "$app daemon for Pleroma" --log_path=systemd
#=================================================
# START SYSTEMD SERVICE

View file

@ -8,7 +8,6 @@
source _common.sh
source ynh_package_version
source ynh_detect_arch__2
source /usr/share/yunohost/helpers
#=================================================
@ -21,7 +20,6 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
@ -29,7 +27,7 @@ random_key=$(ynh_app_setting_get --app=$app --key=random_key)
name=$(ynh_app_setting_get --app=$app --key=name)
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=psqlpwd)
cache=$(ynh_app_setting_get --app=$app --key=cache)
size=$(ynh_app_setting_get --app=$app --key=size)
registration=$(ynh_app_setting_get --app=$app --key=registration)
@ -41,20 +39,26 @@ ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=1
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=0
is_public=0
fi
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app)
@ -80,18 +84,13 @@ then
ynh_app_setting_delete --app=$app --key=psqlpwd
fi
#Close a port
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
if yunohost firewall list | grep -q "\- $port$"
then
ynh_script_progression --message="Closing port $port..."
ynh_exec_warn_less yunohost firewall disallow TCP $port
ynh_app_setting_delete --app=$app --key=is_public
fi
# Remove old repository
ynh_secure_remove --file="/etc/apt/sources.list.d/erlang-solutions.list"
apt-key del A14F4FCA
#=================================================
# CHECK VERSION NUMBER
#=================================================
@ -105,19 +104,12 @@ abort_if_up_to_date
previous_version="${version}"
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
ynh_script_progression --message="Making sure dedicated system user exists..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# STANDARD UPGRADE STEPS
@ -191,6 +183,10 @@ then
ynh_setup_source --dest_dir="$final_path/$app" --source_id=$architecture
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -219,14 +215,6 @@ ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
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"
#=================================================
# SPECIFIC UPGRADE
#=================================================
@ -244,7 +232,7 @@ ynh_backup_if_checksum_is_different --file="$config"
ynh_script_progression --message="Making upgrade..."
# Give permission to the final_path
chown -R "$app":"$app" "$final_path"
chown -R $app: "$final_path"
pushd $final_path/$app
su "$app" -s $SHELL -lc "$final_path/$app/bin/pleroma_ctl migrate"
@ -267,26 +255,11 @@ ynh_script_progression --message="Upgrading systemd configuration..."
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
ynh_script_progression --message="Integrating service in YunoHost..."
# Set permissions on app files
chown -R "$app":"$app" "$final_path"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Upgrading SSOwat configuration..."
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
fi
yunohost service add $app --description "$app daemon for Pleroma" --log_path=systemd
#=================================================
# START SYSTEMD SERVICE

View file

@ -1,25 +0,0 @@
#!/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
}