diff --git a/README.md b/README.md index fc10cfc..5539aa6 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,7 @@ An admin user is created at installation, the login is what you provided at inst # Github -Pulling works fine. But pushing still needs some love. Please read [Weblate's documentation about this](https://docs.weblate.org/en/latest/vcs.html). - -I understant we need to manually install [hub](https://github.com/github/hub), a tool that creates pull-requests. -Which will require to download and install a binary file, as Debian 8 don't have Go>=1.8 +You'll need to give weblate a github user and a token. Please read [github's documentation about token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). ## Weblate and databases @@ -21,4 +18,4 @@ Carefull, this application install PostgreSQL and change the default configurati ## LDAP connexion -It doesn't work yet, but while [it looks doable](https://docs.weblate.org/en/latest/admin/auth.html?highlight=LDAP#ldap-authentication), I'm unsure it is a good idea to link this kind of tools to you LDAP. +It doesn't work yet, but while [it looks doable](https://docs.weblate.org/en/latest/admin/auth.html?highlight=LDAP#ldap-authentication), I'm unsure it is a good idea to connect this kind of tools to your LDAP. diff --git a/check_process b/check_process index 5d11d13..5f35358 100644 --- a/check_process +++ b/check_process @@ -9,6 +9,8 @@ path="/path" (PATH) admin="john" (USER) is_public=1 (PUBLIC|public=1|private=0) + github_account="myaccount" + github_token="myoauthtoken" password="pass" ; Checks pkg_linter=1 diff --git a/conf/hub_config b/conf/hub_config new file mode 100644 index 0000000..289ab03 --- /dev/null +++ b/conf/hub_config @@ -0,0 +1,4 @@ +github.com: +- user: __GITHUBUSER__ + oauth_token: __GITHUBTOKEN__ + protocol: https diff --git a/manifest.json b/manifest.json index ef27c50..04132f4 100644 --- a/manifest.json +++ b/manifest.json @@ -53,6 +53,22 @@ "en": "Choose an admin user for Weblate" }, "example": "simon" + }, + { + "name": "github_account", + "type": "text", + "ask": { + "en": "Github's username" + }, + "example": "simon" + }, + { + "name": "github_token", + "type": "text", + "ask": { + "en": "Github's token (oauth)" + }, + "example": "simon" } ] } diff --git a/scripts/install b/scripts/install index 5e9ca3b..b4d8ad3 100755 --- a/scripts/install +++ b/scripts/install @@ -24,6 +24,8 @@ domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC +github_account=$YNH_APP_ARG_GITHUB_ACCOUNT +github_token=$YNH_APP_ARG_GITHUB_TOKEN # This is a multi-instance app, meaning it can be installed several times independently # The id of the app as stated in the manifest is available as $YNH_APP_ID @@ -63,6 +65,8 @@ ynh_app_setting_set "$app" path "$path_url" ynh_app_setting_set "$app" admin "$admin" ynh_app_setting_set "$app" is_public "$is_public" ynh_app_setting_set "$app" final_path "$final_path" +ynh_app_setting_set "$app" github_account "$github_account" +ynh_app_setting_set "$app" github_token "$github_token" #================================================= # STANDARD MODIFICATIONS @@ -102,9 +106,49 @@ ynh_add_nginx_config # CREATE DEDICATED USER #================================================= -# Create system user for email notifications +# Hub needs a home directory with a config file smtp_pwd=$(ynh_string_random) -ynh_system_user_create "$app" "/home/$app" +ynh_system_user_create "$app" "$final_path" +# Allow bash for our user, so he can use Hub +chsh --shell /bin/bash "$app" + +#================================================= +# Download and install hub +#================================================= + +arch=$(dpkg --print-architecture) +version="hub-linux-${arch}-2.3.0-pre10" +file_bin="hub-linux-${arch}-2.3.0-pre10.tgz" +wget --quiet "https://github.com/github/hub/releases/download/v2.3.0-pre10/${file_bin}" + +case "$arch" in +"386") + sha256sum="08e29a118577b57f962c7c6e4c2e4bfc72b23df1469f2339631c55454893e24f" + ;; +"amd64") + sha256sum="015297eb81e8fe11f3989d8f65c213111e508cecf0e9de8af1b7741de2077320" + ;; +"arm") + sha256sum="a05cd6a42c973177c2a0b457451e9eef0035be67c666e4beebe3b9ed6d526f3d" + ;; +"arm64") + sha256sum="6d845601196ef26342b8bafa9ab6e98c88270fb6dad60e0915396ba5486d0c76" + ;; +*) + sha256sum="-1" + ;; +esac + +[[ $(sha256sum "$file_bin" | cut -d' ' -f1) = $sha256sum ]] || ynh_die "Hub's sha256sum failed (arch: ${arch})" + +tar --extract --file "$file_bin" "$version/bin/hub" +mkdir "$final_path/bin/" +mv "$version/bin/hub" "$final_path/bin/" + +mkdir "$final_path/.config/" +cp ../conf/hub_config "$final_path/.config/hub" +ynh_replace_string "__GITHUBUSER__" "$github_account" "$final_path/.config/hub" +ynh_replace_string "__GITHUBTOKEN__" "$github_token" "$final_path/.config/hub" #================================================= # SPECIFIC SETUP @@ -136,7 +180,9 @@ virtualenv "${final_path}/venv" set +eu source "${final_path}/venv/bin/activate" "${final_path}/venv/bin/pip" install Weblate==2.16 - "${final_path}/venv/bin/pip" install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 django_sendmail_backend python-memcached + "${final_path}/venv/bin/pip" install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 python-memcached + # specific to YunoHost package: + "${final_path}/venv/bin/pip" install django_sendmail_backend ) #================================================= diff --git a/scripts/restore b/scripts/restore index 5eb3d8d..e25c093 100755 --- a/scripts/restore +++ b/scripts/restore @@ -63,6 +63,8 @@ ynh_restore_file "$final_path" # Create the dedicated user (if not existing) ynh_system_user_create "$app" "/home/$app" +# Allow bash for our user, so he can use hub +chsh --shell /bin/bash "$app" #================================================= # RESTORE USER RIGHTS diff --git a/scripts/upgrade b/scripts/upgrade index c4fbfaa..4cebee9 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -65,6 +65,7 @@ ynh_add_nginx_config # Create a system user ynh_system_user_create "$app" "/home/$app" +chsh --shell /bin/bash "$app" #================================================= # SPECIFIC UPGRADE @@ -78,7 +79,9 @@ ynh_system_user_create "$app" "/home/$app" set +eu source "${final_path}/venv/bin/activate" "${final_path}/venv/bin/pip" install Weblate==2.16 - "${final_path}/venv/bin/pip" install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 + "${final_path}/venv/bin/pip" install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 python-memcached + # specific to YunoHost package: + "${final_path}/venv/bin/pip" install django_sendmail_backend ) #=================================================