mirror of
https://framagit.org/YunoHost-Apps/gitea_ynh.git
synced 2024-11-24 03:51:35 +01:00
60cb5e5ae4
* Move app install dir from /opt to /var/www * Revamp the way binaries are downloaded thanks to manifestv2 (no need to check for arch, etc) * Remove custom helpers (exec_as, ynh_handle_app_migration) * Rename LFS_KEY as LFS_JWT_SECRET and KEY as SECRET_KEY as named in app.ini * Add JWT_SECRET for oauth and INTERNAL_TOKEN in app.ini * update upstream sample app.ini URL * Disable actions for now. * Automatically add ssh permissions to the system user * Remove support for upgrade before 1.6.4. Edit test_upgrade_from accordingly.
64 lines
2.1 KiB
Bash
64 lines
2.1 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# DEFINE ALL COMMON FONCTIONS
|
|
#=================================================
|
|
|
|
_gitea_mkdirs() {
|
|
mkdir -p "$install_dir/data"
|
|
mkdir -p "$install_dir/custom/conf"
|
|
_gitea_permissions_install_dir
|
|
|
|
mkdir -p "$data_dir/.ssh"
|
|
mkdir -p "$data_dir/repositories"
|
|
mkdir -p "$data_dir/data/avatars"
|
|
mkdir -p "$data_dir/data/attachments"
|
|
chown -R "$app:$app" "$data_dir"
|
|
chmod -R u=rwX,g=rX,o= "$data_dir"
|
|
chmod -R u=rwx,g=,o= "$data_dir/.ssh"
|
|
|
|
mkdir -p "/var/log/$app"
|
|
touch "/var/log/$app/gitea.log"
|
|
chown -R "$app:$app" "/var/log/$app"
|
|
chmod -R u=rwX,g=rX,o= "/var/log/$app"
|
|
}
|
|
|
|
_gitea_permissions_install_dir() {
|
|
chown -R "$app:$app" "$install_dir"
|
|
chmod -R u=rwX,g=rX,o= "$install_dir"
|
|
}
|
|
|
|
_gitea_set_secrets() {
|
|
if [[ -z "${internal_token:-}" ]]; then
|
|
internal_token=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret INTERNAL_TOKEN)
|
|
ynh_app_setting_set --app "$app" --key internal_token --value="$internal_token"
|
|
fi
|
|
|
|
if [[ -z "${secret_key:-}" ]]; then
|
|
secret_key=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret SECRET_KEY)
|
|
ynh_app_setting_set --app "$app" --key secret_key --value="$secret_key"
|
|
fi
|
|
|
|
if [[ -z "${jwt_secret:-}" ]]; then
|
|
jwt_secret=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET)
|
|
ynh_app_setting_set --app "$app" --key jwt_secret --value="$jwt_secret"
|
|
fi
|
|
|
|
if [[ -n "${lfs_key:-}" ]]; then
|
|
# Migration
|
|
lfs_jwt_secret="$lfs_key"
|
|
ynh_app_setting_delete --app "$app" --key lfs_key
|
|
ynh_app_setting_set --app "$app" --key lfs_jwt_secret --value="$lfs_jwt_secret"
|
|
fi
|
|
|
|
if [[ -z "${lfs_jwt_secret:-}" ]]; then
|
|
lfs_jwt_secret=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET)
|
|
ynh_app_setting_set --app "$app" --key lfs_jwt_secret --value="$lfs_jwt_secret"
|
|
fi
|
|
}
|
|
|
|
_gitea_add_config() {
|
|
ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+")
|
|
ynh_add_config --template="app.ini" --destination="$install_dir/custom/conf/app.ini"
|
|
}
|