1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/misskey_ynh.git synced 2024-09-03 19:46:03 +02:00
This commit is contained in:
ericgaspar 2021-01-11 21:44:02 +01:00
parent 0895d1a43f
commit d180a4063f
No known key found for this signature in database
GPG key ID: 574F281483054D44
11 changed files with 151 additions and 181 deletions

View file

@ -9,7 +9,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview ## Overview
[Misskey](https://join.misskey.page/en/) is a forever evolving, sophisticated microblogging platform that support Fediverse. It provide another flavour to decentralised network. Why don't you take a short break from the hustle and bustle of the city, and dive into a new Internet? [Misskey](https://join.misskey.page/en/) is a forever evolving, sophisticated microblogging platform that support Fediverse. It provide another flavour to decentralised network. Why don't you take a short break from the hustle and bustle of the city, and dive into a new Internet?
**Shipped version:** 12.47.1 **Shipped version:** 12.66.0
## Screenshots ## Screenshots

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/syuilo/misskey/archive/12.47.1.tar.gz SOURCE_URL=https://github.com/syuilo/misskey/archive/12.66.0.tar.gz
SOURCE_SUM=59154273ae1f20187cc69689f4c03eb230c2d3a47e830affb0aaa57b71c49b0b SOURCE_SUM=bdba1e3c1fd0de1044df068464850c3230c9c7218d8a691493602ab8b5f80f5c
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true

View file

@ -4,9 +4,11 @@ Description=__APP__ daemon running
[Service] [Service]
Type=simple Type=simple
User=__APP__ User=__APP__
ExecStart=/usr/local/bin/npm start Group=__APP__
WorkingDirectory=__FINALPATH__ WorkingDirectory=__FINALPATH__
Environment="PATH=__ENV_PATH__"
Environment="NODE_ENV=production" Environment="NODE_ENV=production"
ExecStart=__YNH_NPM__ start
TimeoutSec=60 TimeoutSec=60
StandardOutput=syslog StandardOutput=syslog
StandardError=syslog StandardError=syslog

View file

@ -6,7 +6,7 @@
"en": "Microblogging platform", "en": "Microblogging platform",
"fr": "Microblogging platform" "fr": "Microblogging platform"
}, },
"version": "12.47.1~ynh1", "version": "12.66.0~ynh1",
"url": "https://join.misskey.page/en/", "url": "https://join.misskey.page/en/",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"maintainer": { "maintainer": {

View file

@ -9,7 +9,7 @@ MEMORY_NEEDED="2560"
# dependencies used by the app # dependencies used by the app
pkg_dependencies=" build-essential python ffmpeg redis-server redis-tools postgresql postgresql-contrib" pkg_dependencies=" build-essential python ffmpeg redis-server redis-tools postgresql postgresql-contrib"
NODEJS_VERSION="12" nodejs_version=12
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
@ -22,3 +22,97 @@ NODEJS_VERSION="12"
#================================================= #=================================================
# FUTURE OFFICIAL HELPERS # FUTURE OFFICIAL HELPERS
#================================================= #=================================================
#!/bin/bash
# Add swap
#
# usage: ynh_add_swap --size=SWAP in Mb
# | arg: -s, --size= - Amount of SWAP to add in Mb.
ynh_add_swap () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [s]=size= )
local size
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
local swap_max_size=$(( $size * 1024 ))
local free_space=$(df --output=avail / | sed 1d)
# Because we don't want to fill the disk with a swap file, divide by 2 the available space.
local usable_space=$(( $free_space / 2 ))
SD_CARD_CAN_SWAP=${SD_CARD_CAN_SWAP:-0}
# Swap on SD card only if it's is specified
if ynh_is_main_device_a_sd_card && [ "$SD_CARD_CAN_SWAP" == "0" ]
then
ynh_print_warn --message="The main mountpoint of your system '/' is on an SD card, swap will not be added to prevent some damage of this one, but that can cause troubles for the app $app. If you still want activate the swap, you can relaunch the command preceded by 'SD_CARD_CAN_SWAP=1'"
return
fi
# Compare the available space with the size of the swap.
# And set a acceptable size from the request
if [ $usable_space -ge $swap_max_size ]
then
local swap_size=$swap_max_size
elif [ $usable_space -ge $(( $swap_max_size / 2 )) ]
then
local swap_size=$(( $swap_max_size / 2 ))
elif [ $usable_space -ge $(( $swap_max_size / 3 )) ]
then
local swap_size=$(( $swap_max_size / 3 ))
elif [ $usable_space -ge $(( $swap_max_size / 4 )) ]
then
local swap_size=$(( $swap_max_size / 4 ))
else
echo "Not enough space left for a swap file" >&2
local swap_size=0
fi
# If there's enough space for a swap, and no existing swap here
if [ $swap_size -ne 0 ] && [ ! -e /swap_$app ]
then
# Preallocate space for the swap file, fallocate may sometime not be used, use dd instead in this case
if ! fallocate -l ${swap_size}K /swap_$app
then
dd if=/dev/zero of=/swap_$app bs=1024 count=${swap_size}
fi
chmod 0600 /swap_$app
# Create the swap
mkswap /swap_$app
# And activate it
swapon /swap_$app
# Then add an entry in fstab to load this swap at each boot.
echo -e "/swap_$app swap swap defaults 0 0 #Swap added by $app" >> /etc/fstab
fi
}
ynh_del_swap () {
# If there a swap at this place
if [ -e /swap_$app ]
then
# Clean the fstab
sed -i "/#Swap added by $app/d" /etc/fstab
# Desactive the swap file
swapoff /swap_$app
# And remove it
rm /swap_$app
fi
}
# Check if the device of the main mountpoint "/" is an SD card
#
# [internal]
#
# return 0 if it's an SD card, else 1
ynh_is_main_device_a_sd_card () {
local main_device=$(lsblk --output PKNAME --noheadings $(findmnt / --nofsroot --uniq --output source --noheadings --first-only))
if echo $main_device | grep --quiet "mmc" && [ $(tail -n1 /sys/block/$main_device/queue/rotational) == "0" ]
then
return 0
else
return 1
fi
}

View file

@ -49,17 +49,12 @@ ynh_backup --src_path="$final_path"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD
#================================================= #=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app.service"
#================================================= #=================================================
# BACKUP THE POSTGRESQL DATABASE # BACKUP THE POSTGRESQL DATABASE
#================================================= #=================================================

View file

@ -8,7 +8,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
source ynh_add_swap
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
@ -67,9 +66,9 @@ ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." ynh_script_progression --message="Installing dependencies..."
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
@ -79,8 +78,8 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
ynh_script_progression --message="Creating a POSTGRESQL database..." ynh_script_progression --message="Creating a POSTGRESQL database..."
# Create postgresql database # Create postgresql database
db_name="${app}" db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$app db_user=$db_name
db_pwd=$(ynh_string_random --length=8) db_pwd=$(ynh_string_random --length=8)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name 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_set --app=$app --key=db_pwd --value=$db_pwd
@ -123,7 +122,7 @@ ynh_script_progression --message="Configuring nginx web server..."
### `ynh_add_nginx_config` will use the file conf/nginx.conf ### `ynh_add_nginx_config` will use the file conf/nginx.conf
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config 'port' ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -133,56 +132,17 @@ ynh_script_progression --message="Configuring system user..."
# Create a system user # Create a system user
ynh_system_user_create --username=$app ynh_system_user_create --username=$app
#=================================================
# SPECIFIC SETUP
#=================================================
# ...
#=================================================
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config
ynh_add_systemd_config
# Set right permissions for curl install
chown -R $app: $final_path
# Remove the public access
if [ $is_public -eq 0 ]
then
ynh_app_setting_delete --app=$app --key=skipped_uris
fi
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
### `ynh_replace_string` is used to replace a string in a file. cp -f ../conf/default.yml "$final_path/.config/default.yml"
### (It's compatible with sed regular expressions syntax)
config="$final_path/.config/default.yml" ynh_replace_string --match_string="__DB_USER__" --replace_string="$app" --target_file="$final_path/.config/default.yml"
cp -f ../conf/default.yml "$config" ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/.config/default.yml"
ynh_replace_string --match_string="__DB_USER__" --replace_string="$app" --target_file="$config" ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/.config/default.yml"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/.config/default.yml"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/.config/default.yml"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config"
#=================================================
# INSTALLING MISKKEY
#=================================================
pushd "$final_path"
yarn add ts-node webpack
NODE_ENV=production yarn build
yarn run init
popd
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
@ -191,6 +151,16 @@ popd
# 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="$config" ynh_store_file_checksum --file="$config"
#=================================================
# INSTALLING MISKKEY
#=================================================
pushd "$final_path"
ynh_exec_warn_lessyarn add ts-node webpack
ynh_exec_warn_less NODE_ENV=production yarn build
ynh_exec_warn_less yarn run init
popd
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
@ -200,6 +170,13 @@ ynh_store_file_checksum --file="$config"
# Set permissions to app files # Set permissions to app files
chown -R $app: $final_path chown -R $app: $final_path
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1
yunohost service add $app --description="A interplanetary blogging platform" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================

View file

@ -8,7 +8,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
source ynh_add_swap
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
@ -77,20 +76,9 @@ ynh_script_progression --message="Removing nginx web server configuration..." --
# Remove the dedicated nginx config # Remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
# Remove swap # Remove swap
ynh_del_swap ynh_del_swap
#=================================================
# 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
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
#================================================= #=================================================

View file

@ -9,7 +9,6 @@
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts #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
source ../settings/scripts/ynh_add_swap
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
@ -49,7 +48,10 @@ test ! -d $final_path \
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
@ -88,7 +90,6 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then
swap_needed=$(($MEMORY_NEEDED - $total_memory)) swap_needed=$(($MEMORY_NEEDED - $total_memory))
fi fi
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
@ -97,8 +98,10 @@ fi
ynh_script_progression --message="Reinstalling dependencies..." ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies # Define and install dependencies
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
@ -115,25 +118,26 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
#================================================= #=================================================
# INSTALLING MISKKEY # INSTALLING MISKKEY
#================================================= #=================================================
pushd "$final_path" pushd "$final_path"
yarn add ts-node webpack yarn add ts-node webpack
NODE_ENV=production yarn build NODE_ENV=production yarn build
popd popd
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service systemctl enable $app.service --quiet
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "A short description of the app" --log "systemd" --line_match="All workers started" yunohost service add $app --description "A interplanetary blogging platform" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -142,7 +146,6 @@ ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="All workers started" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="All workers started"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -8,7 +8,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
source ynh_add_swap
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
@ -105,8 +104,10 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." ynh_script_progression --message="Upgrading dependencies..."
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#================================================= #=================================================
@ -149,11 +150,14 @@ ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_f
#================================================= #=================================================
# Updating process MISSKEY # Updating process MISSKEY
#================================================= #=================================================
pushd "$final_path" pushd "$final_path"
yarn add ts-node webpack ynh_exec_warn_lessyarn add ts-node webpack
NODE_ENV=production yarn build ynh_exec_warn_less NODE_ENV=production yarn build
ynh_exec_warn_less yarn run init
popd popd
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
@ -188,7 +192,7 @@ chown -R $app: $final_path
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "$app service" ---log_type "systemd" yunohost service add $app --description "A interplanetary blogging platform" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE

View file

@ -1,93 +0,0 @@
#!/bin/bash
# Add swap
#
# usage: ynh_add_swap --size=SWAP in Mb
# | arg: -s, --size= - Amount of SWAP to add in Mb.
ynh_add_swap () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [s]=size= )
local size
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
local swap_max_size=$(( $size * 1024 ))
local free_space=$(df --output=avail / | sed 1d)
# Because we don't want to fill the disk with a swap file, divide by 2 the available space.
local usable_space=$(( $free_space / 2 ))
SD_CARD_CAN_SWAP=${SD_CARD_CAN_SWAP:-0}
# Swap on SD card only if it's is specified
if ynh_is_main_device_a_sd_card && [ "$SD_CARD_CAN_SWAP" == "0" ]
then
ynh_print_warn --message="The main mountpoint of your system '/' is on an SD card, swap will not be added to prevent some damage of this one, but that can cause troubles for the app $app. If you still want activate the swap, you can relaunch the command preceded by 'SD_CARD_CAN_SWAP=1'"
return
fi
# Compare the available space with the size of the swap.
# And set a acceptable size from the request
if [ $usable_space -ge $swap_max_size ]
then
local swap_size=$swap_max_size
elif [ $usable_space -ge $(( $swap_max_size / 2 )) ]
then
local swap_size=$(( $swap_max_size / 2 ))
elif [ $usable_space -ge $(( $swap_max_size / 3 )) ]
then
local swap_size=$(( $swap_max_size / 3 ))
elif [ $usable_space -ge $(( $swap_max_size / 4 )) ]
then
local swap_size=$(( $swap_max_size / 4 ))
else
echo "Not enough space left for a swap file" >&2
local swap_size=0
fi
# If there's enough space for a swap, and no existing swap here
if [ $swap_size -ne 0 ] && [ ! -e /swap_$app ]
then
# Preallocate space for the swap file, fallocate may sometime not be used, use dd instead in this case
if ! fallocate -l ${swap_size}K /swap_$app
then
dd if=/dev/zero of=/swap_$app bs=1024 count=${swap_size}
fi
chmod 0600 /swap_$app
# Create the swap
mkswap /swap_$app
# And activate it
swapon /swap_$app
# Then add an entry in fstab to load this swap at each boot.
echo -e "/swap_$app swap swap defaults 0 0 #Swap added by $app" >> /etc/fstab
fi
}
ynh_del_swap () {
# If there a swap at this place
if [ -e /swap_$app ]
then
# Clean the fstab
sed -i "/#Swap added by $app/d" /etc/fstab
# Desactive the swap file
swapoff /swap_$app
# And remove it
rm /swap_$app
fi
}
# Check if the device of the main mountpoint "/" is an SD card
#
# [internal]
#
# return 0 if it's an SD card, else 1
ynh_is_main_device_a_sd_card () {
local main_device=$(lsblk --output PKNAME --noheadings $(findmnt / --nofsroot --uniq --output source --noheadings --first-only))
if echo $main_device | grep --quiet "mmc" && [ $(tail -n1 /sys/block/$main_device/queue/rotational) == "0" ]
then
return 0
else
return 1
fi
}