#!/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 admin=$YNH_APP_ARG_ADMIN # Source YunoHost helpers source /usr/share/yunohost/helpers # Save app settings ynh_app_setting_set "$app" is_public "$is_public" mailadmin=$(ynh_user_get_info $admin mail) # Check domain/path availability sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \ || ynh_die "Path not available: ${domain}${path_url}" # Add gitlab repository sudo apt-get install -yy curl openssh-server ca-certificates postfix apt-transport-https curl -L https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey | sudo apt-key add - sudo apt-get update sudo apt-get install -yy debian-archive-keyring sudo cp ../conf/gitlab-ce.list /etc/apt/sources.list.d/gitlab-ce.list sudo apt-get update sudo apt-get install -yy gitlab-ce # Gitlab configuration 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 echo $admin echo $mailadmin echo "newuser = User.new({ \"email\"=>'$mailadmin', \"username\"=>'$admin', \"name\"=>'$admin', \"password\"=>'12345678'}) newuser.admin = true newuser.confirmed_at = Time.now newuser.confirmation_token = nil newuser.save" | sudo gitlab-rails console sudo gitlab-ctl reconfigure # Set permissions to app files # you may need to make some file and/or directory writeable by www-data (nginx user) # sudo chown -R root: $src_path # 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 sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf # 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