2017-06-10 10:10:31 +02:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
|
|
|
|
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
|
|
|
|
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
|
|
|
|
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
|
|
|
|
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
|
|
|
|
# The app instance name is probably what you are interested the most, since this is
|
|
|
|
|
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
|
|
|
|
# db names, ...
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
|
|
# Retrieve arguments
|
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
|
path_url=$YNH_APP_ARG_PATH
|
|
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
2017-06-28 15:41:05 +02:00
|
|
|
|
admin=$YNH_APP_ARG_ADMIN
|
2017-06-10 10:10:31 +02:00
|
|
|
|
|
|
|
|
|
# Source YunoHost helpers
|
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
|
|
# Save app settings
|
|
|
|
|
ynh_app_setting_set "$app" is_public "$is_public"
|
|
|
|
|
|
2017-06-28 15:41:05 +02:00
|
|
|
|
mailadmin=$(ynh_user_get_info $admin mail)
|
2017-06-28 16:28:20 +02:00
|
|
|
|
port=$(ynh_find_port 8080)
|
|
|
|
|
rdmPass=$(ynh_string_random 30)
|
2017-06-28 15:41:05 +02:00
|
|
|
|
|
2017-06-10 10:10:31 +02:00
|
|
|
|
# Check domain/path availability
|
|
|
|
|
sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \
|
|
|
|
|
|| ynh_die "Path not available: ${domain}${path_url}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Add gitlab repository
|
2017-06-10 17:32:57 +02:00
|
|
|
|
sudo apt-get install -yy curl openssh-server ca-certificates postfix apt-transport-https
|
2017-06-10 12:42:02 +02:00
|
|
|
|
curl -L https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey | sudo apt-key add -
|
|
|
|
|
sudo apt-get update
|
2017-06-10 17:32:57 +02:00
|
|
|
|
sudo apt-get install -yy debian-archive-keyring
|
2017-06-10 13:07:56 +02:00
|
|
|
|
sudo cp ../conf/gitlab-ce.list /etc/apt/sources.list.d/gitlab-ce.list
|
2017-06-10 12:33:37 +02:00
|
|
|
|
sudo apt-get update
|
2017-06-10 17:32:57 +02:00
|
|
|
|
sudo apt-get install -yy gitlab-ce
|
2017-06-10 10:35:32 +02:00
|
|
|
|
|
2017-06-10 10:10:31 +02:00
|
|
|
|
|
|
|
|
|
# Gitlab configuration
|
2017-06-28 15:41:05 +02:00
|
|
|
|
|
|
|
|
|
sed -i "s@GENERATED_EXTERNAL_URL@https://$domain@" ../conf/gitlab.rb
|
|
|
|
|
sed -i "s@PORT@$port@" ../conf/gitlab.rb
|
|
|
|
|
|
|
|
|
|
sudo cp -f ../conf/gitlab.rb /etc/gitlab/gitlab.rb
|
|
|
|
|
sudo gitlab-ctl reconfigure
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
newuser.save" | sudo gitlab-rails console
|
|
|
|
|
|
2017-06-10 10:10:31 +02:00
|
|
|
|
sudo gitlab-ctl reconfigure
|
|
|
|
|
|
2017-06-12 22:30:17 +02:00
|
|
|
|
|
2017-06-10 10:10:31 +02:00
|
|
|
|
|
2017-06-28 15:41:05 +02:00
|
|
|
|
|
2017-06-10 10:10:31 +02:00
|
|
|
|
# Set permissions to app files
|
|
|
|
|
# you may need to make some file and/or directory writeable by www-data (nginx user)
|
2017-06-13 07:28:48 +02:00
|
|
|
|
# sudo chown -R root: $src_path
|
2017-06-10 10:10:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
|
|
|
nginx_conf=../conf/nginx.conf
|
|
|
|
|
sed -i "s@YNH_WWW_PATH@$path_url@g" $nginx_conf
|
2017-06-28 16:54:03 +02:00
|
|
|
|
# sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf
|
2017-06-10 10:10:31 +02:00
|
|
|
|
# If a dedicated php-fpm process is used:
|
|
|
|
|
# Don't forget to modify ../conf/nginx.conf accordingly or your app will not work!
|
|
|
|
|
# sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf
|
|
|
|
|
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If app is public, add url to SSOWat conf as skipped_uris
|
|
|
|
|
if [[ $is_public -eq 1 ]]; then
|
|
|
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
|
|
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Reload services
|
|
|
|
|
sudo service nginx reload
|