2017-06-10 10:10:31 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-12-16 23:05:12 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
2018-12-19 00:02:20 +01:00
|
|
|
#=================================================
|
|
|
|
|
2018-12-16 23:05:12 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
# Load common variables and helpers
|
|
|
|
source ./_common.sh
|
2017-06-10 10:10:31 +02:00
|
|
|
|
2018-12-19 00:02:20 +01:00
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS
|
|
|
|
#=================================================
|
|
|
|
|
2017-06-10 10:10:31 +02:00
|
|
|
# Retrieve arguments
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
path_url=$YNH_APP_ARG_PATH
|
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
2019-01-13 16:01:54 +01:00
|
|
|
use_web_account=$YNH_APP_ARG_USE_WEB_ACCOUNT
|
2017-06-28 15:41:05 +02:00
|
|
|
admin=$YNH_APP_ARG_ADMIN
|
2017-06-10 10:10:31 +02:00
|
|
|
|
2018-12-19 00:02:20 +01:00
|
|
|
#=================================================
|
|
|
|
# REGISTER DOMAIN
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Normalize the url path syntax
|
|
|
|
path_url=$(ynh_normalize_url_path $path_url)
|
|
|
|
|
|
|
|
# This function check also the availability of this one
|
2018-12-16 23:05:12 +01:00
|
|
|
ynh_webpath_register $app $domain $path_url
|
2017-06-10 10:10:31 +02:00
|
|
|
|
2018-12-19 00:02:20 +01:00
|
|
|
#=================================================
|
|
|
|
# REGISTER DOMAIN
|
|
|
|
#=================================================
|
|
|
|
|
2018-12-16 23:05:12 +01:00
|
|
|
# Check user parameter
|
2019-01-26 14:46:52 +01:00
|
|
|
ynh_user_exists "$admin" ||
|
|
|
|
ynh_die "The chosen admin user does not exist."
|
2017-06-10 10:10:31 +02:00
|
|
|
|
2018-12-19 00:02:20 +01:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2017-06-28 15:41:05 +02:00
|
|
|
|
2018-12-16 23:05:12 +01:00
|
|
|
ynh_app_setting_set $app admin $admin
|
|
|
|
ynh_app_setting_set $app path_url $path_url
|
|
|
|
ynh_app_setting_set $app is_public $is_public
|
2019-01-13 16:01:54 +01:00
|
|
|
ynh_app_setting_set $app use_web_account $use_web_account
|
2018-12-19 00:02:20 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
# FIND AND OPEN PORTS
|
|
|
|
#=================================================
|
|
|
|
|
2019-01-26 14:30:58 +01:00
|
|
|
ynh_print_info "Getting ports..."
|
|
|
|
|
2018-12-19 00:02:20 +01:00
|
|
|
# Find free ports
|
|
|
|
port=$(ynh_find_port 8080)
|
2019-01-22 15:47:54 +01:00
|
|
|
portUnicorn=$(ynh_find_port $(($port + 1)))
|
2018-12-19 00:02:20 +01:00
|
|
|
|
|
|
|
yunohost firewall allow --no-upnp TCP $port 2>&1
|
|
|
|
yunohost firewall allow --no-upnp TCP $portUnicorn 2>&1
|
2018-12-16 23:05:12 +01:00
|
|
|
ynh_app_setting_set $app web_port $port
|
|
|
|
ynh_app_setting_set $app unicorn_port $portUnicorn
|
2017-06-10 10:10:31 +02:00
|
|
|
|
2018-12-16 23:05:12 +01:00
|
|
|
#=================================================
|
2018-12-19 00:02:20 +01:00
|
|
|
# NGINX CONFIGURATION
|
2018-12-16 23:05:12 +01:00
|
|
|
#=================================================
|
2017-06-10 10:10:31 +02:00
|
|
|
|
2018-12-19 00:02:20 +01:00
|
|
|
# Create a dedicated nginx config
|
2018-12-19 00:34:06 +01:00
|
|
|
ynh_add_nginx_config
|
2017-06-10 10:35:32 +02:00
|
|
|
|
2018-12-19 00:02:20 +01:00
|
|
|
#=================================================
|
|
|
|
# CONFIGURE GITLAB
|
|
|
|
#=================================================
|
2017-06-10 10:10:31 +02:00
|
|
|
|
2018-12-16 23:05:12 +01:00
|
|
|
# Configure gitlab with gitlab.rb file
|
|
|
|
config_gitlab
|
2017-06-28 15:41:05 +02:00
|
|
|
|
2018-12-19 00:02:20 +01:00
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
|
|
|
|
2018-12-16 23:05:12 +01:00
|
|
|
ynh_install_app_dependencies openssh-server
|
2017-06-28 15:41:05 +02:00
|
|
|
|
2018-12-19 00:02:20 +01:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND INSTALL GITLAB
|
|
|
|
#=================================================
|
2017-06-28 15:41:05 +02:00
|
|
|
|
2018-12-16 23:05:12 +01:00
|
|
|
setup_source $architecture
|
2017-06-28 15:41:05 +02:00
|
|
|
|
2018-12-19 00:02:20 +01:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
2018-12-24 16:25:32 +01:00
|
|
|
# GETTING ADMIN INFO AND ADD AS A GITLAB USER AND CONFIGURE SIGN IN SYSTEM
|
2018-12-19 00:02:20 +01:00
|
|
|
#=================================================
|
|
|
|
|
2019-01-26 14:30:58 +01:00
|
|
|
ynh_print_info "Creating an administrator user..."
|
|
|
|
|
2018-12-19 00:02:20 +01:00
|
|
|
mailadmin=$(ynh_user_get_info $admin mail)
|
|
|
|
rdmPass=$(ynh_string_random 30)
|
|
|
|
|
2017-06-28 16:28:20 +02:00
|
|
|
echo "newuser = User.new({ \"email\"=>'$mailadmin', \"username\"=>'$admin', \"name\"=>'$admin', \"password\"=>'$rdmPass'})
|
2017-06-28 15:41:05 +02:00
|
|
|
newuser.admin = true
|
|
|
|
newuser.confirmed_at = Time.now
|
|
|
|
newuser.confirmation_token = nil
|
2018-12-24 16:25:32 +01:00
|
|
|
newuser.save
|
2019-02-09 14:36:32 +01:00
|
|
|
ApplicationSetting.last.update_attributes(password_authentication_enabled_for_web: $use_web_account, signup_enabled: $use_web_account)" | gitlab-rails console
|
2017-06-28 15:41:05 +02:00
|
|
|
|
2018-12-19 00:02:20 +01:00
|
|
|
#=================================================
|
|
|
|
# RESTART TO TAKE INTO ACCOUNT CHANGES
|
|
|
|
#=================================================
|
|
|
|
|
2019-02-09 14:36:32 +01:00
|
|
|
gitlab-ctl reconfigure
|
2017-06-10 10:10:31 +02:00
|
|
|
|
2018-12-19 00:02:20 +01:00
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
|
|
|
|
2017-06-10 10:10:31 +02:00
|
|
|
# If app is public, add url to SSOWat conf as skipped_uris
|
|
|
|
if [[ $is_public -eq 1 ]]; then
|
2019-01-26 14:46:52 +01:00
|
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
|
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
2017-06-10 10:10:31 +02:00
|
|
|
fi
|
|
|
|
|
2018-12-19 00:02:20 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALISATION
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
|
2019-01-05 15:22:23 +01:00
|
|
|
systemctl reload nginx
|
2018-12-19 00:02:20 +01:00
|
|
|
|
|
|
|
#=================================================
|
2019-01-13 15:44:16 +01:00
|
|
|
# WAIT
|
2018-12-19 00:02:20 +01:00
|
|
|
#=================================================
|
|
|
|
|
2019-01-26 14:46:52 +01:00
|
|
|
waiting_to_start
|