mirror of
https://github.com/YunoHost-Apps/weblate_ynh.git
synced 2024-10-01 13:35:04 +02:00
commit
c43084eec6
7 changed files with 79 additions and 32 deletions
|
@ -5,8 +5,9 @@
|
||||||
is_public=1
|
is_public=1
|
||||||
admin="john"
|
admin="john"
|
||||||
password="1Strong-Password"
|
password="1Strong-Password"
|
||||||
github_account="myaccount"
|
used_forge="GitLab"
|
||||||
github_token="myoauthtoken"
|
forge_username="myusername"
|
||||||
|
forge_token="myoauthtoken"
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=1
|
setup_sub_dir=1
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
github.com:
|
github.com:
|
||||||
- user: __GITHUB_ACCOUNT__
|
- user: __FORGE_USERNAME__
|
||||||
oauth_token: __GITHUB_TOKEN__
|
oauth_token: __FORGE_TOKEN__
|
||||||
protocol: https
|
protocol: https
|
||||||
|
|
|
@ -229,13 +229,13 @@ TEMPLATES = [
|
||||||
|
|
||||||
# GitHub username and token for sending pull requests.
|
# GitHub username and token for sending pull requests.
|
||||||
# Please see the documentation for more details.
|
# Please see the documentation for more details.
|
||||||
GITHUB_USERNAME = "__GITHUB_ACCOUNT__"
|
GITHUB_USERNAME = __GITHUB_USERNAME__
|
||||||
GITHUB_TOKEN = "__GITHUB_TOKEN__"
|
GITHUB_TOKEN = __GITHUB_TOKEN__
|
||||||
|
|
||||||
# GitLab username and token for sending merge requests.
|
# GitLab username and token for sending merge requests.
|
||||||
# Please see the documentation for more details.
|
# Please see the documentation for more details.
|
||||||
GITLAB_USERNAME = None
|
GITLAB_USERNAME = __GITLAB_USERNAME__
|
||||||
GITLAB_TOKEN = None
|
GITLAB_TOKEN = __GITLAB_TOKEN__
|
||||||
|
|
||||||
# Authentication configuration
|
# Authentication configuration
|
||||||
AUTHENTICATION_BACKENDS = (
|
AUTHENTICATION_BACKENDS = (
|
||||||
|
|
|
@ -58,20 +58,30 @@
|
||||||
"type": "password"
|
"type": "password"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "github_account",
|
"name": "used_forge",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "GitHub's username",
|
"en":"Choose the forge you use",
|
||||||
"fr": "Nom d'utilisateur de GitHub"
|
"fr":"Choisissez la forge que vous utilisez"
|
||||||
},
|
},
|
||||||
"example": "Github account"
|
"choices": ["GitHub", "GitLab"],
|
||||||
|
"default": "GitHub"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "github_token",
|
"name": "forge_username",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "GitHub's token (OAuth)",
|
"en": "Your forge's username",
|
||||||
"fr": "Jeton GitHub (OAuth)"
|
"fr": "Nom d'utilisateur de votre forge"
|
||||||
|
},
|
||||||
|
"example": "Your username"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "forge_token",
|
||||||
|
"type": "string",
|
||||||
|
"ask": {
|
||||||
|
"en": "Your forge's token (OAuth)",
|
||||||
|
"fr": "Jeton de votre forge (OAuth)"
|
||||||
},
|
},
|
||||||
"example": "A secret token"
|
"example": "A secret token"
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,20 @@ fi
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
set_forge_variables() {
|
||||||
|
if [ $used_forge = "GitHub" ] ; then
|
||||||
|
github_username="\"$forge_username\""
|
||||||
|
github_token="\"$forge_token\""
|
||||||
|
gitlab_username="None"
|
||||||
|
gitlab_token="None"
|
||||||
|
else
|
||||||
|
github_username="None"
|
||||||
|
github_token="None"
|
||||||
|
gitlab_username="\"$forge_username\""
|
||||||
|
gitlab_token="\"$forge_token\""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# EXPERIMENTAL HELPERS
|
# EXPERIMENTAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -28,8 +28,9 @@ path_url=$YNH_APP_ARG_PATH
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
password=$YNH_APP_ARG_PASSWORD
|
password=$YNH_APP_ARG_PASSWORD
|
||||||
github_account=$YNH_APP_ARG_GITHUB_ACCOUNT
|
used_forge=$YNH_APP_ARG_USED_FORGE
|
||||||
github_token=$YNH_APP_ARG_GITHUB_TOKEN
|
forge_username=$YNH_APP_ARG_FORGE_USERNAME
|
||||||
|
forge_token=$YNH_APP_ARG_FORGE_TOKEN
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -55,8 +56,9 @@ ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||||
ynh_app_setting_set --app=$app --key=github_account --value=$github_account
|
ynh_app_setting_set --app=$app --key=used_forge --value=$used_forge
|
||||||
ynh_app_setting_set --app=$app --key=github_token --value=$github_token
|
ynh_app_setting_set --app=$app --key=forge_username --value=$forge_username
|
||||||
|
ynh_app_setting_set --app=$app --key=forge_token --value=$forge_token
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
|
@ -128,6 +130,8 @@ ynh_secure_remove --file="$tempdir"
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE HUB
|
# CONFIGURE HUB
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
if [ $used_forge = "GitHub" ] ; then
|
||||||
ynh_script_progression --message="Configure hub..." --weight=1
|
ynh_script_progression --message="Configure hub..." --weight=1
|
||||||
|
|
||||||
mkdir "$final_path/.config/"
|
mkdir "$final_path/.config/"
|
||||||
|
@ -136,6 +140,7 @@ ynh_add_config --template="../conf/hub_config" --destination="$final_path/.confi
|
||||||
cat <<EOF > "$final_path/.bashrc"
|
cat <<EOF > "$final_path/.bashrc"
|
||||||
eval "$(hub alias -s /bin/bash)"
|
eval "$(hub alias -s /bin/bash)"
|
||||||
EOF
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PIP INSTALLATION
|
# PIP INSTALLATION
|
||||||
|
@ -174,6 +179,8 @@ ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"
|
||||||
path_url="${path_url%/}"
|
path_url="${path_url%/}"
|
||||||
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
|
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
|
||||||
|
|
||||||
|
set_forge_variables
|
||||||
|
|
||||||
ynh_add_config --template="../conf/settings.py" --destination="$settings"
|
ynh_add_config --template="../conf/settings.py" --destination="$settings"
|
||||||
ynh_add_config --template="../conf/celery-weblate" --destination="$final_path/celery-weblate"
|
ynh_add_config --template="../conf/celery-weblate" --destination="$final_path/celery-weblate"
|
||||||
ynh_add_config --template="../conf/uwsgi.ini" --destination="/etc/uwsgi/apps-available/$app.ini"
|
ynh_add_config --template="../conf/uwsgi.ini" --destination="/etc/uwsgi/apps-available/$app.ini"
|
||||||
|
|
|
@ -23,8 +23,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||||
github_account=$(ynh_app_setting_get --app=$app --key=github_account)
|
used_forge=$(ynh_app_setting_get --app=$app --key=used_forge)
|
||||||
github_token=$(ynh_app_setting_get --app=$app --key=github_token)
|
forge_username=$(ynh_app_setting_get --app=$app --key=forge_username)
|
||||||
|
forge_token=$(ynh_app_setting_get --app=$app --key=forge_token)
|
||||||
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
||||||
|
|
||||||
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
|
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
|
||||||
|
@ -33,7 +34,6 @@ key=$(ynh_string_random --length=50)
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Checking version..."
|
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
|
@ -88,6 +88,16 @@ then
|
||||||
ynh_secure_remove --file="/var/log/$app-celery"
|
ynh_secure_remove --file="/var/log/$app-celery"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If used_forge, forge_username, forge_token don't exist, create them
|
||||||
|
if [ -z "$used_forge" ]; then
|
||||||
|
used_forge="GitHub"
|
||||||
|
forge_username=$(ynh_app_setting_get --app=$app --key=github_account)
|
||||||
|
forge_token=$(ynh_app_setting_get --app=$app --key=github_token)
|
||||||
|
ynh_app_setting_set --app=$app --key=used_forge --value=$used_forge
|
||||||
|
ynh_app_setting_set --app=$app --key=forge_username --value=$forge_username
|
||||||
|
ynh_app_setting_set --app=$app --key=forge_token --value=$forge_token
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -129,14 +139,17 @@ ynh_secure_remove --file="$tempdir"
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE HUB
|
# CONFIGURE HUB
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configure hub..." --weight=2
|
|
||||||
|
|
||||||
mkdir -p "$final_path/.config/"
|
if [ $used_forge = "GitHub" ] ; then
|
||||||
|
ynh_script_progression --message="Configure hub..." --weight=1
|
||||||
|
|
||||||
|
#mkdir "$final_path/.config/"
|
||||||
ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub"
|
ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub"
|
||||||
|
|
||||||
cat <<EOF > "$final_path/.bashrc"
|
cat <<EOF > "$final_path/.bashrc"
|
||||||
eval "$(hub alias -s /bin/bash)"
|
eval "$(hub alias -s /bin/bash)"
|
||||||
EOF
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE A CONFIG FILE
|
# UPDATE A CONFIG FILE
|
||||||
|
@ -198,6 +211,8 @@ upgrade() {
|
||||||
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
|
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
|
||||||
path_url="${path_url%/}"
|
path_url="${path_url%/}"
|
||||||
|
|
||||||
|
set_forge_variables
|
||||||
|
|
||||||
ynh_add_config --template="../conf/settings.py" --destination="$settings"
|
ynh_add_config --template="../conf/settings.py" --destination="$settings"
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"
|
ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"
|
||||||
|
|
Loading…
Reference in a new issue