From 95eee12a93f30fcf09905d995cae50ddd9f13610 Mon Sep 17 00:00:00 2001 From: Gabriel Cossette Date: Fri, 25 Jun 2021 22:32:09 +0000 Subject: [PATCH] Continuer --- scripts/_common.sh | 2 +- scripts/install | 137 ++++++++++++--------------------------------- 2 files changed, 37 insertions(+), 102 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 3b80ce9..409abe2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,7 +3,7 @@ # COMMON VARIABLES #================================================= -pkg_dependencies="vim build-essential git zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev python-docutils pkg-config cmake nodejs graphviz ruby2.5 bundler default-libmysqlclient-dev jq python-requests bsdmainutils" +pkg_dependencies="zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev libicu-dev python-docutils pkg-config cmake nodejs graphviz ruby2.5 bundler default-libmysqlclient-dev runit" ---------------- diff --git a/scripts/install b/scripts/install index 7a6fc4c..3c4eddc 100755 --- a/scripts/install +++ b/scripts/install @@ -36,7 +36,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Validating installation parameters..." -final_path=/var/www/$app +final_path=/home/huginn test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path @@ -53,6 +53,7 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=admin_pwd --value=$admin_pwd ynh_app_setting_set --app=$app --key=invitation --value=$invitation ynh_app_setting_set --app=$app --key=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=final_path --value=$final_path #================================================= # STANDARD MODIFICATIONS @@ -61,19 +62,10 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= ynh_script_progression --message="Installing dependencies..." --weight=10 -#Import node.js repository (can be skipped on Ubuntu and Debian Jessie): -# curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash - - ynh_install_app_dependencies $pkg_dependencies -# Install the bundler and foreman gems: - -gem install rake foreman --no-document -gem install bundler -v '< 2' --no-document - -# Update rubygems: - -gem update --system --no-document +#Install foreman gem +gem install foreman #================================================= # CREATE DEDICATED USER @@ -91,6 +83,11 @@ ynh_script_progression --message="Creating a MySQL database..." --weight=2 ynh_app_setting_set --app=$app --key=db_name --value=huginn ynh_mysql_setup_db --db_user=huginn --db_name=huginn +#================================================= +# DOWNLOAD SOURCE +#================================================= +ynh_script_progression --message="Setting up source files..." + # We'll install Huginn into the home directory of the user "huginn" cd /home/huginn @@ -119,13 +116,16 @@ sudo sudo -u huginn -H chmod o-rwx .env sudo sudo -u huginn -H cp config/unicorn.rb.example config/unicorn.rb #Install Gems -sudo sudo -u huginn -H bundle install --deployment --without development test +#sudo sudo -u huginn -H bundle install --deployment --without development test + +#RUN bundle install --path vendor/bundle --deployment --without development test +sudo -u huginn -H bundle lock --update rails +sudo -u huginn -H bundle install --path vendor/bundle #rake secret RAKE_SECRET=$(sudo sudo -u huginn -H rake secret) #Edit .env - sudo sudo -u huginn -H sed -i "s/\(DATABASE_PASSWORD *= *\).*/\1\"$db_pwd\"/" .env sudo sudo -u huginn -H sed -i "s/\(DATABASE_USERNAME *= *\).*/\1\"huginn\"/" .env sudo sudo -u huginn -H sed -i "s/\(DATABASE_NAME *= *\).*/\1huginn/" .env @@ -155,6 +155,28 @@ cd /home/huginn/huginn/ #Export the init scripts: sudo rake production:export + + + + + +#USER root +CMD ["bundle", "exec", "foreman", "start"] + + + + + + + + + + + + + + + #================================================= # SETUP LOGROTATE #================================================= @@ -194,24 +216,7 @@ sudo yunohost app ssowatconf -#================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= -ynh_script_progression --message="Setting up source files..." - -# Load the last available version -source upgrade.d/upgrade.last.sh -# Create an app.src for the last version of nextcloud -cat > ../conf/app.src << EOF -SOURCE_URL=https://download.nextcloud.com/server/releases/nextcloud-$next_version.tar.bz2 -SOURCE_SUM=$nextcloud_source_sha256 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.bz2 -SOURCE_IN_SUBDIR=true -EOF - -ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Enable YunoHost patches on Nextcloud sources cp -a ../sources/patches_last_version/* ../sources/patches # Download, check integrity, uncompress and patch the source from app.src @@ -245,76 +250,6 @@ fi # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SPECIFIC SETUP -#================================================= -# INSTALL NEXTCLOUD -#================================================= -ynh_script_progression --message="Installing Nextcloud..." --weight=30 - -# Define a function to execute commands with `occ` -exec_occ() { - (cd "$final_path" && ynh_exec_as "$app" \ - php${phpversion} occ --no-interaction --no-ansi "$@") -} - -# Set write access for the following commands -chown -R $app: "$final_path" "$datadir" - -# Define password in an intermediate var -# The fact that it's called _password allows it to be -# picked up by Yunohost's auto-redact mecanism -admin_password="$(ynh_string_random --length=6)" - -# Install Nextcloud using a temporary admin user -exec_occ maintenance:install \ - --database "mysql" --database-name $db_name \ - --database-user $db_name --database-pass "$db_pwd" \ - --admin-user "admin" --admin-pass "$admin_password" \ - --data-dir "$datadir" \ - || ynh_die --message="Unable to install Nextcloud" - -#================================================= -# CONFIGURE NEXTCLOUD -#================================================= -ynh_script_progression --message="Configuring Nextcloud..." --weight=8 - -# Ensure that UpdateNotification app is disabled -exec_occ app:disable updatenotification - -# Enable LDAP plugin -exec_occ app:enable user_ldap -exec_occ ldap:create-empty-config - -# Load the installation config file in Nextcloud -nc_conf="$final_path/config_install.json" -ynh_add_config --template="../conf/config_install.json" --destination="$nc_conf" - -exec_occ config:import "$nc_conf" - -# Then remove the config file -ynh_secure_remove --file="$nc_conf" - -# Load the additional config file (used also for upgrade) -nc_conf="$final_path/config.json" -ynh_add_config --template="../conf/config.json" --destination="$nc_conf" - -exec_occ config:import "$nc_conf" - -# Then remove the config file -ynh_secure_remove --file="$nc_conf" - -#================================================= -# ADD A CRON JOB -#================================================= - -cron_path="/etc/cron.d/$app" -ynh_add_config --template="../conf/nextcloud.cron" --destination="$cron_path" -chown root: "$cron_path" -chmod 644 "$cron_path" - -exec_occ background:cron - #================================================= # GENERIC FINALIZATION