|
|
@ -36,7 +36,7 @@ app=$YNH_APP_INSTANCE_NAME |
|
|
#================================================= |
|
|
#================================================= |
|
|
ynh_script_progression --message="Validating installation parameters..." |
|
|
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" |
|
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" |
|
|
|
|
|
|
|
|
# Register (book) web path |
|
|
# 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=admin_pwd --value=$admin_pwd |
|
|
ynh_app_setting_set --app=$app --key=invitation --value=$invitation |
|
|
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=is_public --value=$is_public |
|
|
|
|
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path |
|
|
|
|
|
|
|
|
#================================================= |
|
|
#================================================= |
|
|
# STANDARD MODIFICATIONS |
|
|
# 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 |
|
|
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 |
|
|
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 |
|
|
# 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_app_setting_set --app=$app --key=db_name --value=huginn |
|
|
ynh_mysql_setup_db --db_user=huginn --db_name=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" |
|
|
# We'll install Huginn into the home directory of the user "huginn" |
|
|
cd /home/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 |
|
|
sudo sudo -u huginn -H cp config/unicorn.rb.example config/unicorn.rb |
|
|
|
|
|
|
|
|
#Install Gems |
|
|
#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 |
|
|
RAKE_SECRET=$(sudo sudo -u huginn -H rake secret) |
|
|
RAKE_SECRET=$(sudo sudo -u huginn -H rake secret) |
|
|
|
|
|
|
|
|
#Edit .env |
|
|
#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_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_USERNAME *= *\).*/\1\"huginn\"/" .env |
|
|
sudo sudo -u huginn -H sed -i "s/\(DATABASE_NAME *= *\).*/\1huginn/" .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: |
|
|
#Export the init scripts: |
|
|
sudo rake production:export |
|
|
sudo rake production:export |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#USER root |
|
|
|
|
|
CMD ["bundle", "exec", "foreman", "start"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#================================================= |
|
|
#================================================= |
|
|
# SETUP LOGROTATE |
|
|
# 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 |
|
|
# Enable YunoHost patches on Nextcloud sources |
|
|
cp -a ../sources/patches_last_version/* ../sources/patches |
|
|
cp -a ../sources/patches_last_version/* ../sources/patches |
|
|
# Download, check integrity, uncompress and patch the source from app.src |
|
|
# Download, check integrity, uncompress and patch the source from app.src |
|
|
@ -245,76 +250,6 @@ fi |
|
|
# Create a dedicated NGINX config |
|
|
# Create a dedicated NGINX config |
|
|
ynh_add_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 |
|
|
# GENERIC FINALIZATION |
|
|
|