2018-02-11 01:20:58 +01:00
|
|
|
#=================================================
|
|
|
|
# SET ALL CONSTANTS
|
|
|
|
#=================================================
|
2016-12-27 10:44:40 +01:00
|
|
|
|
2024-04-26 23:35:01 +02:00
|
|
|
readonly time_zone="$(cat /etc/timezone)"
|
|
|
|
readonly python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)"
|
2024-05-30 23:22:07 +02:00
|
|
|
systemd_seafile_bind_mount="$data_dir/seafile-data:/opt/seafile/seafile-data "
|
|
|
|
systemd_seafile_bind_mount+="$data_dir/seahub-data:/opt/seafile/seahub-data "
|
|
|
|
systemd_seafile_bind_mount+="/var/log/$app:/opt/seafile/logs "
|
|
|
|
systemd_seafile_bind_mount+="$install_dir/conf:/opt/seafile/conf "
|
2024-06-02 20:56:48 +02:00
|
|
|
systemd_seafile_bind_mount+="$install_dir/ccnet:/opt/seafile/ccnet "
|
2024-05-30 23:22:07 +02:00
|
|
|
systemd_seafile_bind_mount+="/proc "
|
|
|
|
systemd_seafile_bind_mount+="/dev"
|
2017-12-09 20:56:20 +01:00
|
|
|
|
2024-04-12 22:19:27 +02:00
|
|
|
# Create special path with / at the end
|
2024-04-26 23:35:14 +02:00
|
|
|
if [[ "$path" == '/' ]]
|
2024-04-12 22:19:27 +02:00
|
|
|
then
|
2024-04-26 23:35:01 +02:00
|
|
|
readonly path2="$path"
|
2024-04-12 22:19:27 +02:00
|
|
|
else
|
2024-04-26 23:35:01 +02:00
|
|
|
readonly path2="$path/"
|
2024-04-12 22:19:27 +02:00
|
|
|
fi
|
|
|
|
|
2024-04-26 23:35:01 +02:00
|
|
|
if [ "${LANG:0:2}" == C. ]; then
|
|
|
|
readonly language=en
|
|
|
|
else
|
|
|
|
readonly language="${LANG:0:2}"
|
|
|
|
fi
|
2024-04-12 21:22:21 +02:00
|
|
|
|
2018-02-11 01:20:58 +01:00
|
|
|
#=================================================
|
|
|
|
# DEFINE ALL COMMON FONCTIONS
|
|
|
|
#=================================================
|
|
|
|
|
2024-05-30 23:22:07 +02:00
|
|
|
run_seafile_cmd() {
|
2024-08-31 02:59:12 +02:00
|
|
|
ynh_hide_warnings systemd-run --wait --uid="$app" --gid="$app" \
|
2024-05-30 23:22:07 +02:00
|
|
|
--property=RootDirectory="$install_dir"/seafile_image \
|
|
|
|
--property="BindPaths=$systemd_seafile_bind_mount" \
|
|
|
|
$@
|
2017-01-31 23:25:17 +01:00
|
|
|
}
|
|
|
|
|
2024-04-12 21:22:21 +02:00
|
|
|
install_source() {
|
2024-06-01 11:19:38 +02:00
|
|
|
ynh_setup_source_custom --dest_dir="$install_dir"/seafile_image --full_replace
|
2024-06-02 21:48:38 +02:00
|
|
|
mkdir -p "$install_dir"/seafile_image/opt/seafile/{seafile-data,seahub-data,conf,ccnet,logs}
|
2024-05-30 23:22:07 +02:00
|
|
|
grep "^$app:x" /etc/passwd | sed "s|$install_dir|/opt/seafile|" >> "$install_dir"/seafile_image/etc/passwd
|
|
|
|
grep "^$app:x" /etc/group >> "$install_dir"/seafile_image/etc/group
|
|
|
|
grep "^$app:x" /etc/group- >> "$install_dir"/seafile_image/etc/group-
|
|
|
|
grep "^$app:" /etc/shadow >> "$install_dir"/seafile_image/etc/shadow
|
2024-04-12 21:22:21 +02:00
|
|
|
}
|
|
|
|
|
2019-06-11 22:28:26 +02:00
|
|
|
set_permission() {
|
2024-06-02 22:15:10 +02:00
|
|
|
chown -R "$app:$app" "$install_dir"/{conf,ccnet}
|
|
|
|
chmod -R u+rwX,g-w,o= "$install_dir"/{conf,ccnet}
|
2024-05-30 23:22:07 +02:00
|
|
|
chown -R "$app:$app" "$install_dir"/seafile_image/opt/seafile
|
|
|
|
chmod -R u+rwX,g-w,o= "$install_dir"/seafile_image/opt/seafile
|
|
|
|
|
|
|
|
# Allow to www-data to each dir between /opt/yunohost/seafile and /opt/yunohost/seafile/seafile_image/opt/seafile/seahub/media
|
|
|
|
local dir_path=''
|
|
|
|
while read -r -d/ dir_name; do
|
|
|
|
dir_path+="$dir_name/"
|
|
|
|
if [[ "$dir_path" == "$install_dir"* ]] && [ -e "$dir_path" ]; then
|
|
|
|
setfacl -m user:www-data:rX "$dir_path"
|
|
|
|
fi
|
|
|
|
done <<< "$seafile_code/seahub/media"
|
|
|
|
test -e "$install_dir/seafile_image/opt/seafile/seahub-data" && setfacl -m user:www-data:rX "$install_dir/seafile_image/opt/seafile/seahub-data"
|
|
|
|
test -e "$seafile_code/seahub/media" && setfacl -R -m user:www-data:rX "$seafile_code/seahub/media"
|
|
|
|
|
2022-11-02 17:19:55 +01:00
|
|
|
# At install time theses directory are not available
|
2024-04-26 23:35:14 +02:00
|
|
|
test -e "$install_dir"/seahub-data && setfacl -m user:www-data:rX "$data_dir"
|
|
|
|
test -e "$install_dir"/seahub-data && setfacl -R -m user:www-data:rX "$data_dir"/seahub-data
|
2021-06-26 12:22:45 +02:00
|
|
|
|
2024-04-12 21:22:21 +02:00
|
|
|
find "$data_dir" \( \! -perm -o= \
|
|
|
|
-o \! -user "$app" \
|
|
|
|
-o \! -group "$app" \) \
|
|
|
|
-exec chown "$app:$app" {} \; \
|
2023-10-26 10:14:27 +02:00
|
|
|
-exec chmod o= {} \;
|
2019-06-11 22:28:26 +02:00
|
|
|
}
|
2023-09-27 19:21:58 +02:00
|
|
|
|
|
|
|
clean_url_in_db_config() {
|
|
|
|
sql_request='DELETE FROM `constance_config` WHERE `constance_key`= "SERVICE_URL"'
|
2024-08-31 02:59:12 +02:00
|
|
|
ynh_mysql_db_shell <<< "$sql_request" --database=seahubdb
|
2023-09-27 19:21:58 +02:00
|
|
|
sql_request='DELETE FROM `constance_config` WHERE `constance_key`= "FILE_SERVER_ROOT"'
|
2024-08-31 02:59:12 +02:00
|
|
|
ynh_mysql_db_shell <<< "$sql_request" --database=seahubdb
|
2023-09-27 19:21:58 +02:00
|
|
|
}
|
2024-04-12 21:22:21 +02:00
|
|
|
|
|
|
|
ensure_vars_set() {
|
2024-08-31 02:59:12 +02:00
|
|
|
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=jwt_private_key_notification_server --value=$(ynh_string_random -l 32)
|
2024-04-12 21:22:21 +02:00
|
|
|
if [ -z "${jwt_private_key_notification_server:-}" ]; then
|
|
|
|
jwt_private_key_notification_server=$(ynh_string_random -l 32)
|
2024-08-31 02:59:12 +02:00
|
|
|
ynh_app_setting_set --key=jwt_private_key_notification_server --value="$jwt_private_key_notification_server"
|
2024-04-12 21:22:21 +02:00
|
|
|
fi
|
|
|
|
}
|