1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pleroma_ynh.git synced 2024-09-03 20:15:59 +02:00

Apply example_ynh

This commit is contained in:
yalh76 2021-08-25 19:59:06 +02:00
parent 578d780392
commit cb29ae4742
12 changed files with 154 additions and 160 deletions

View file

@ -1,12 +1,12 @@
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
admin="john" (USER)
is_public=1 (PUBLIC|public=1|private=0)
password="pass"
domain="domain.tld"
admin="john"
is_public=1
password="1Strong-Password"
name="My_Pleroma"
registration=0 (BOOLEAN)
cache=1 (BOOLEAN)
registration=0
cache=1
size="5g"
; Checks
pkg_linter=1
@ -16,32 +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
# 2.0.5~ynh1
# upgrade=1 from_commit=06f0005707e77fae566fedbd6e5e37f390df5173
# 2.0.5~ynh2
# upgrade=1 from_commit=30696599937984e9879da22220253f005e290cd0
# 2.0.7~ynh1
# upgrade=1 from_commit=e13745923a2e06e780e7b9d34ae084f600a9a2a2
# 2.1.2~ynh1
# upgrade=1 from_commit=ade89203b611fd178bc9d1cf35804bc08ea3a78b
# 2.2.0~ynh1
upgrade=1 from_commit=059ddc457aabe6962f5960612ed2dc1db53daeeb
# 2.2.2~ynh1
@ -52,6 +26,8 @@
upgrade=1 from_commit=4757df265b0c3e8d1fc5280190ccfe5705dcb691
# 2.3.0~ynh3
upgrade=1 from_commit=28ed2fd7ab7b5e55154991c990d8e780560a56db
# 2.4.0~ynh1
upgrade=1 from_commit=2c4a57afdc92a6428ccfea3ccb74c7e33dc9b9ff
backup_restore=1
multi_instance=0
port_already_use=0
@ -60,32 +36,6 @@
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
name=2.0.5~ynh1
; commit=30696599937984e9879da22220253f005e290cd0
name=2.0.5~ynh2
; commit=e13745923a2e06e780e7b9d34ae084f600a9a2a2
name=2.0.7~ynh1
; commit=ade89203b611fd178bc9d1cf35804bc08ea3a78b
name=2.1.2~ynh1
; commit=059ddc457aabe6962f5960612ed2dc1db53daeeb
name=2.2.0~ynh1
; commit=63723f18af5b035a41e967078cc3128423b1f9ae
@ -96,3 +46,5 @@ Notification=yes
name=2.3.0~ynh2
; commit=28ed2fd7ab7b5e55154991c990d8e780560a56db
name=2.3.0~ynh3
; commit=2c4a57afdc92a6428ccfea3ccb74c7e33dc9b9ff
name=2.4.0~ynh1

0
doc/.gitkeep Normal file
View file

43
doc/DISCLAIMER.md Normal file
View file

@ -0,0 +1,43 @@
* Any known limitations, constrains or stuff not working, such as (but not limited to):
* **Pleroma** require a dedicated **root domain**, eg. pleroma.domain.tld
* **Pleroma** require a valid **certificate** installed on the domain. Yunohost can **install Letsencrypt certificate** on the domain from **admin web-interface** or through **command-line**.
* This package is currently set to **single-instance** that means you can run a **single Pleroma instance** on a **single server**.
* The admin **password** entered when installing must **not** contain **special characters**. (See [issue #132](https://github.com/YunoHost-Apps/pleroma_ynh/issues/132))
* requiring a full dedicated domain ?
* architectures not supported ?
* LDAP supported but HTTP auth not.
* the app requires an important amount of RAM / disk / .. to install or to work properly
* etc...
* Other infos that people should be aware of, such as:
* any specific step to perform after installing (such as manually finishing the install, specific admin credentials, ...)
* how to configure / administrate the application if it ain't obvious
* upgrade process / specificities / things to be aware of ?
* security considerations ?
## Admin Tasks
Go to **cd /var/www/pleroma/pleroma**.
### Adding users
**Run:**
$ ( cd /var/www/pleroma/pleroma && sudo -u pleroma MIX_ENV=prod ./bin/pleroma_ctl user new <NICKNAME> <EMAIL> )
### Password reset
**Run:**
$ ( cd /var/www/pleroma/pleroma && sudo -u pleroma MIX_ENV=prod ./bin/pleroma_ctl user reset_password <NICKNAME> )
This will generate a **password reset link** that you can then send to the user.
### Moderators
You can make users **moderators**. They will then be able to **delete any post**.
**Run:**
$ ( cd /var/www/pleroma/pleroma && sudo -u pleroma MIX_ENV=prod ./bin/pleroma_ctl user set <NICKNAME> --[no-]admin )
**--admin** option will **make the user moderator** and **--no-admin** will **take away the moderator privileges** from the user.

0
doc/screenshots/.gitkeep Normal file
View file

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 KiB

View file

@ -6,8 +6,16 @@
"en": "A free, federated social networking server built on open protocols.",
"fr": "Un serveur de réseautage social fédéré et gratuit basé sur des protocoles ouverts."
},
"version": "2.4.0~ynh1",
"url": "https://git.pleroma.social/pleroma/pleroma",
"version": "2.4.0~ynh2",
"url": "https://pleroma.social/",
"upstream": {
"license": "AGPL-3.0-only",
"website": "https://pleroma.social/",
"demo": "http://distsn.org/pleroma-instances.html",
"admindoc": "https://docs.pleroma.social/",
"userdoc": "https://yunohost.org/apps",
"code": "https://git.pleroma.social/pleroma/pleroma/"
},
"license": "AGPL-3.0-only",
"maintainer": [
{
@ -65,7 +73,7 @@
},
"default": false
},
{
{
"name": "cache",
"type": "boolean",
"ask": {
@ -73,7 +81,7 @@
"fr": "Activer le cache média pour votre instance"
},
"default": true
},
},
{
"name": "size",
"type": "string",
@ -83,7 +91,7 @@
},
"choices": ["2g","5g","10g","20g","40g","80g"],
"default": "5g"
}
}
]
}
}

View file

@ -44,6 +44,12 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$datadir" --is_big
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
@ -69,8 +75,6 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup --src_path="/etc/$app/config.exs"
ynh_backup --src_path="$datadir" --is_big
#=================================================
# BACKUP THE POSTGRESQL DATABASE
#=================================================

View file

@ -30,6 +30,11 @@ ynh_script_progression --message="Loading installation settings..."
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
# Add settings here as needed by your application
#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)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================

View file

@ -95,7 +95,7 @@ ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Configuring 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
#=================================================
# CREATE A POSTGRESQL DATABASE
@ -149,17 +149,14 @@ fi
#=================================================
# SPECIFIC SETUP
#=================================================
# CREATE THE DATA DIRECTORY
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating the data directory..."
ynh_script_progression --message="Creating a data directory..."
# Define app's data directory
datadir="/home/yunohost.app/${app}"
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
# Create app folders
mkdir -p "$datadir/"
mkdir -p $datadir
mkdir -p "$datadir/uploads/"
mkdir -p "$datadir/static/"
mkdir -p "$datadir/static/emoji/"
@ -169,9 +166,9 @@ chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir"
#=================================================
# CREATE THE CONFIG DIRECTORY
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Creating the config directory..."
ynh_script_progression --message="Adding a configuration file..."
mkdir -p /etc/$app
chown -R $app /etc/$app
@ -191,9 +188,6 @@ ynh_add_systemd_config
#=================================================
ynh_script_progression --message="Making setup..."
# Give permission to the final_path
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 \
@ -261,6 +255,9 @@ then
ynh_permission_update --permission="main" --add="visitors"
fi
# Everyone can access to the api part
# We don't want to display the tile in the sso so we put --show_tile="false"
# And we don't want that the YunoHost Admin can remove visitors group to this permission, so we put --protected="true"
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true"
#=================================================

View file

@ -36,19 +36,14 @@ then
fi
#=================================================
# STOP ALL PLEROMA SERVICES
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping all pleroma services..."
ynh_script_progression --message="Stopping and removing the systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped $app"
pkill -u $app
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config
@ -98,9 +93,9 @@ fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE CONFIGURATION
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing configuration..."
ynh_script_progression --message="Removing various files..."
# Remove the config directory securely
ynh_secure_remove --file="/etc/$app"

View file

@ -67,7 +67,7 @@ fi
ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# RESTORE THE APP MAIN DIR
@ -81,17 +81,14 @@ chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#=================================================
# SPECIFIC RESTORATION
# RESTORE THE DATA DIRECTORY
#=================================================
# RECREATE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Recreating the data directory..."
ynh_script_progression --message="Restoring the data directory..."
# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup.
ynh_restore_file --origin_path="$datadir" --not_mandatory
# Create app folders
mkdir -p "$datadir/"
mkdir -p $datadir
mkdir -p "$datadir/uploads/"
mkdir -p "$datadir/static/"
mkdir -p "$datadir/static/emoji/"
@ -101,15 +98,7 @@ chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir"
#=================================================
# RESTORE THE CONFIG FILE
#=================================================
ynh_script_progression --message="Restoring the config file..."
ynh_restore_file --origin_path="/etc/$app/config.exs"
chmod 400 "/etc/$app/config.exs"
chown $app:$app "/etc/$app/config.exs"
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
@ -131,6 +120,16 @@ ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS citext;" --databa
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";" --database=$db_name
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..."
ynh_restore_file --origin_path="/etc/$app/config.exs"
chmod 400 "/etc/$app/config.exs"
chown $app:$app "/etc/$app/config.exs"
#=================================================
# RESTORE SYSTEMD
#=================================================

View file

@ -40,48 +40,6 @@ ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
# Create a permission if needed
if ! ynh_permission_exists --permission="api"; then
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true"
fi
#Switch variables name
psql_db=$(ynh_app_setting_get --app=$app --key=psql_db)
if [ -n "$psql_db" ]
then
db_name=$(ynh_app_setting_get --app=$app --key=psql_db)
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
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_app_setting_delete --app=$app --key=psql_db
ynh_app_setting_delete --app=$app --key=psqlpwd
fi
#Close a port
if yunohost firewall list | grep -q "\- $port$"
then
ynh_script_progression --message="Closing port $port..."
ynh_exec_warn_less yunohost firewall disallow TCP $port
fi
# Remove old repository
ynh_secure_remove --file="/etc/apt/sources.list.d/erlang-solutions.list"
apt-key del A14F4FCA
#=================================================
# CHECK VERSION NUMBER
#=================================================
@ -122,13 +80,54 @@ if ynh_version_gt "${previous_version}" "1.1.1~ynh1" ; then
pkill -u $app
fi
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
# Create a permission if needed
if ! ynh_permission_exists --permission="api"; then
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true"
fi
#Switch variables name
psql_db=$(ynh_app_setting_get --app=$app --key=psql_db)
if [ -n "$psql_db" ]
then
db_name=$(ynh_app_setting_get --app=$app --key=psql_db)
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
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_app_setting_delete --app=$app --key=psql_db
ynh_app_setting_delete --app=$app --key=psqlpwd
fi
#Close a port
if yunohost firewall list | grep -q "\- $port$"
then
ynh_script_progression --message="Closing port $port..."
ynh_exec_warn_less yunohost firewall disallow TCP $port
fi
# Remove old repository
ynh_secure_remove --file="/etc/apt/sources.list.d/erlang-solutions.list"
apt-key del A14F4FCA
#=================================================
# 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"
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# UPGRADE TO OTP RELEASE
@ -221,15 +220,6 @@ ynh_install_app_dependencies $pkg_dependencies
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a config file..."
config="/etc/$app/config.exs"
ynh_backup_if_checksum_is_different --file="$config"
#=================================================
# MAKE UPGRADE
#=================================================
@ -240,12 +230,13 @@ pushd $final_path/$app
popd
#=================================================
# STORE THE CONFIG FILE CHECKSUM
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Storing the config file checksum..."
ynh_script_progression --message="Updating a configuration file..."
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$config"
config="/etc/$app/config.exs"
ynh_backup_if_checksum_is_different --file="$config"
chmod 400 "$config"
chown $app:$app "$config"