1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nextcloud_ynh.git synced 2024-09-03 19:55:57 +02:00

Merge pull request #411 from YunoHost-Apps/fix_linter

Linters stuff: get rid of ynh_replace_string and multimedia helper now official
This commit is contained in:
Kayou 2021-05-27 10:51:36 +02:00 committed by GitHub
commit 56fb717f65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 28 additions and 90 deletions

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://download.nextcloud.com/server/releases/nextcloud-__VERSION__.tar.bz2
SOURCE_SUM=__SHA256_SUM__
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.bz2
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

View file

@ -1 +1 @@
*/15 * * * * __USER__ /usr/bin/php__PHPVERSION__ -f __FINALPATH__/cron.php
*/15 * * * * __APP__ /usr/bin/php__PHPVERSION__ -f __FINAL_PATH__/cron.php

View file

@ -1,5 +1,6 @@
#!/bin/bash
user=$1
user="$1"
app="$(basename $0 | cut -d- -f 2-)" # Extract the app name from the script name, which is supposed to be something like "50-app_id"
sudo setfacl --modify g:__GROUP__:rwx /home/$user
setfacl --modify g:$app:rwx /home/$user

View file

@ -22,7 +22,7 @@
"email": "pierre@kayou.io"
},
"requirements": {
"yunohost": ">= 4.1.6"
"yunohost": ">= 4.2"
},
"multi_instance": true,
"services": [

View file

@ -102,42 +102,3 @@ ynh_smart_mktemp () {
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================
#=================================================
# YUNOHOST MULTIMEDIA INTEGRATION
#=================================================
# Install or update the main directory yunohost.multimedia
#
# usage: ynh_multimedia_build_main_dir
ynh_multimedia_build_main_dir () {
local ynh_media_release="v1.2"
local checksum="806a827ba1902d6911095602a9221181"
# Download yunohost.multimedia scripts
wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz 2>&1
# Check the control sum
echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \
|| ynh_die "Corrupt source"
# Check if the package acl is installed. Or install it.
ynh_package_is_installed 'acl' \
|| ynh_package_install acl
# Extract
mkdir yunohost.multimedia-master
tar -xf ${ynh_media_release}.tar.gz -C yunohost.multimedia-master --strip-components 1
./yunohost.multimedia-master/script/ynh_media_build.sh
}
# Grant write access to multimedia directories to a specified user
#
# usage: ynh_multimedia_addaccess user_name
#
# | arg: user_name - User to be granted write access
ynh_multimedia_addaccess () {
local user_name=$1
groupadd -f multimedia
usermod -a -G multimedia $user_name
}

View file

@ -111,7 +111,7 @@ then
exec_occ config:system:set trusted_domains 1 --value=$new_domain
# Change hostname for activity notifications
ynh_replace_string --match_string="'overwrite.cli.url' => 'http://${old_domain}'," --replace_string="'overwrite.cli.url' => 'https://${new_domain}'," --target_file="${final_path}/config/config.php"
exec_occ config:system:set overwrite.cli.url --value="https://${new_domain}"
fi
if [ $change_domain -eq 1 ]

View file

@ -73,10 +73,15 @@ ynh_script_progression --message="Setting up source files..."
# Load the last available version
source upgrade.d/upgrade.last.sh
# Create an app.src for the last version of nextcloud
cp ../conf/app.src.default ../conf/app.src
ynh_replace_string --match_string="__VERSION__" --replace_string="$next_version" --target_file="../conf/app.src"
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$nextcloud_source_sha256" --target_file="../conf/app.src"
cat > ../conf/app.src << EOF
SOURCE_URL=https://download.nextcloud.com/server/releases/nextcloud-$next_version.tar.bz2
SOURCE_SUM=$nextcloud_source_sha256
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.bz2
SOURCE_IN_SUBDIR=true
EOF
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Enable YunoHost patches on Nextcloud sources
@ -171,10 +176,8 @@ exec_occ ldap:create-empty-config
# Load the installation config file in Nextcloud
nc_conf="$final_path/config_install.json"
cp ../conf/config_install.json "$nc_conf"
ynh_add_config --template="../conf/config_install.json" --destination="$nc_conf"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$nc_conf"
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$nc_conf"
exec_occ config:import "$nc_conf"
# Then remove the config file
@ -182,9 +185,8 @@ ynh_secure_remove --file="$nc_conf"
# Load the additional config file (used also for upgrade)
nc_conf="$final_path/config.json"
cp ../conf/config.json "$nc_conf"
ynh_add_config --template="../conf/config.json" --destination="$nc_conf"
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$nc_conf"
exec_occ config:import "$nc_conf"
# Then remove the config file
@ -243,7 +245,7 @@ exec_occ config:system:get logout_url >/dev/null 2>&1 \
# CHANGE HOSTNAME FOR ACTIVITY NOTIFICATIONS
#=================================================
ynh_replace_string --match_string="'overwrite.cli.url' => 'http://localhost'," --replace_string="'overwrite.cli.url' => 'https://${domain}'," --target_file="${final_path}/config/config.php"
exec_occ config:system:set overwrite.cli.url --value="https://${domain}"
#=================================================
# REMOVE THE TEMPORARY ADMIN AND SET THE TRUE ONE
@ -267,14 +269,10 @@ ynh_store_file_checksum --file="$final_path/config/config.php"
#=================================================
cron_path="/etc/cron.d/$app"
cp -a ../conf/nextcloud.cron "$cron_path"
ynh_add_config --template="../conf/nextcloud.cron" --destination="$cron_path"
chown root: "$cron_path"
chmod 644 "$cron_path"
ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$cron_path"
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$cron_path"
ynh_replace_string --match_string="__PHPVERSION__" --replace_string="$phpversion" --target_file="$cron_path"
exec_occ background:cron
#=================================================
@ -285,13 +283,6 @@ exec_occ db:add-missing-indices
exec_occ db:add-missing-columns
exec_occ db:convert-filecache-bigint -n
#=================================================
# CONFIGURE THE HOOK FILE FOR USER CREATE
#=================================================
# Set system group in hooks
ynh_replace_string --match_string="__GROUP__" --replace_string="$app" --target_file=../hooks/post_user_create
#=================================================
# YUNOHOST MULTIMEDIA INTEGRATION
#=================================================

View file

@ -267,9 +267,13 @@ then
ynh_print_info --message="Upgrade to nextcloud $next_version"
# Create an app.src for this version of Nextcloud
cp ../conf/app.src.default ../conf/app.src
ynh_replace_string --match_string="__VERSION__" --replace_string="$next_version" --target_file="../conf/app.src"
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$nextcloud_source_sha256" --target_file="../conf/app.src"
cat > ../conf/app.src << EOF
SOURCE_URL=https://download.nextcloud.com/server/releases/nextcloud-$next_version.tar.bz2
SOURCE_SUM=$nextcloud_source_sha256
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.bz2
SOURCE_IN_SUBDIR=true
EOF
# Create a temporary directory
tmpdir="$(ynh_smart_mktemp min_size=300)"
@ -332,9 +336,7 @@ then
ynh_backup_if_checksum_is_different --file="$final_path/config/config.php"
nc_conf="${final_path}/config.json"
cp ../conf/config.json "$nc_conf"
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$nc_conf"
ynh_add_config --template="../conf/config.json" --destination="$nc_conf"
# Reneable the mail app
if [ $mail_app_must_be_reactived -eq 1 ]; then
@ -371,7 +373,7 @@ then
# CHANGE HOSTNAME FOR ACTIVITY NOTIFICATIONS
#=================================================
ynh_replace_string --match_string="'overwrite.cli.url' => 'http://localhost'," --replace_string="'overwrite.cli.url' => 'https://${domain}'," --target_file="${final_path}/config/config.php"
exec_occ config:system:set overwrite.cli.url --value="https://${domain}"
#=================================================
# MOUNT HOME FOLDERS AS EXTERNAL STORAGE
@ -402,23 +404,12 @@ fi
#=================================================
cron_path="/etc/cron.d/$app"
cp -a ../conf/nextcloud.cron "$cron_path"
ynh_add_config --template="../conf/nextcloud.cron" --destination="$cron_path"
chown root: "$cron_path"
chmod 644 "$cron_path"
ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$cron_path"
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$cron_path"
ynh_replace_string --match_string="__PHPVERSION__" --replace_string="$phpversion" --target_file="$cron_path"
exec_occ background:cron
#=================================================
# UPDATE THE HOOK FILE FOR USER CREATE
#=================================================
# Set system group in hooks
ynh_replace_string --match_string="__GROUP__" --replace_string="$app" --target_file=../hooks/post_user_create
#=================================================
# GENERIC FINALIZATION
#=================================================