From 8a288cc743e86b3a3cf8a3b73e3faadb4e2a8d5f Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 24 Jul 2020 12:31:07 +0200 Subject: [PATCH] fix --- .gitignore | 2 - README.md | 5 +- conf/app.src | 8 ++- conf/{db.inc.php => db.example.inc.php} | 6 +- conf/nginx.conf | 2 +- conf/systemd.service | 4 +- manifest.json | 10 ++- scripts/_common.sh | 25 ++++++- scripts/install | 90 ++++++++++++------------- 9 files changed, 84 insertions(+), 68 deletions(-) delete mode 100644 .gitignore rename conf/{db.inc.php => db.example.inc.php} (78%) diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] diff --git a/README.md b/README.md index 0fb2f7c..e41b936 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -Movim for Yunohost. -========== +# Movim for YunoHost [![Integration level](https://dash.yunohost.org/integration/movim.svg)](https://dash.yunohost.org/appci/app/movim) ![](https://ci-apps.yunohost.org/ci/badges/movim.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/movim.maintain.svg) [![Install Movim with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=movim) @@ -8,7 +7,7 @@ Movim is a decentralized social network, written in PHP and HTML5 and based on t It is recommended to use a "valid" certificate to use Movim, auto-signed is sometimes problematic. You might want to take a look a StartSSL or Let's Encrypt. -Provided Movim version: 0.13 +Provided Movim version: 0.18 Please read CHANGELOG. diff --git a/conf/app.src b/conf/app.src index 25328ed..b3baa59 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,4 +1,6 @@ -SOURCE_URL=https://github.com/movim/movim/archive/v0.13.tar.gz -SOURCE_SUM=7aa5b2b6cd97e87a440981cfb6788a6f04ffd5eb4545026c49e1c61771593d11 +SOURCE_URL=https://github.com/movim/movim/archive/v0.18rc11.tar.gz +SOURCE_SUM=6614d09f50d7cd13671dadd0c31af32d65e6309f6ba251d50b8d0d92efdb5cc9 SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz \ No newline at end of file +SOURCE_FORMAT=tar.gz +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= \ No newline at end of file diff --git a/conf/db.inc.php b/conf/db.example.inc.php similarity index 78% rename from conf/db.inc.php rename to conf/db.example.inc.php index e876147..26e9bfb 100644 --- a/conf/db.inc.php +++ b/conf/db.example.inc.php @@ -3,15 +3,15 @@ # You need to copy an rename this file to 'db.inc.php' and complete the values $conf = [ # The type can be 'pgsql' or 'mysql' - 'type' => 'mysql', + 'type' => 'pgsql', # The database username 'username' => '__DB_USER__', # The password 'password' => '__DB_PWD__', # Where can we find the database ? 'host' => 'localhost', - # The port number, 3306 for MySQL and 5432 for PostGreSQL - 'port' => 3306, + # The port number, 3306 for MySQL and 5432 for PostgreSQL + 'port' => 5432, # The database name 'database' => '__DB_NAME__' ]; diff --git a/conf/nginx.conf b/conf/nginx.conf index 0bc59e8..d9bd84a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -15,7 +15,7 @@ location __PATH__/ { } fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php7.3-fpm-__NAME__.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; diff --git a/conf/systemd.service b/conf/systemd.service index 204da6a..339937a 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,6 +1,6 @@ [Unit] -Description=Movim daemon (__APP__) -After=nginx.service network.target local-fs.target mysql.service +Description=Movim daemon +After=nginx.service network.target local-fs.target postgresql.service [Service] Type=simple diff --git a/manifest.json b/manifest.json index 7a8e320..b528fc6 100644 --- a/manifest.json +++ b/manifest.json @@ -5,9 +5,9 @@ "description": { "en": "The Kickass Social Network" }, - "version": "0.13.0~ynh1", + "version": "0.18.0~ynh1", "requirements": { - "yunohost": ">= 3.0" + "yunohost": ">= 3.8.1" }, "url": "https://movim.eu/", "license": "AGPL-3.0-or-later", @@ -18,9 +18,7 @@ }, "services": [ "nginx", - "php5-fpm", - "mysql", - "metronome" + "php7.0-fpm" ], "multi_instance": false, "arguments": { @@ -74,7 +72,7 @@ { "name": "ssoenabled", "ask": { - "en": "Enable SSO support (autologin) ?", + "en": "Enable SSO support (autologin)?", "fr": "Activer le support SSO (connexin auto) ?" }, "choices": ["Yes", "No"], diff --git a/scripts/_common.sh b/scripts/_common.sh index b7a2c22..26d4528 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,7 +1,26 @@ #!/bin/bash -# -# Common variables -# + +#================================================= +# COMMON VARIABLES +#================================================= + +# dependencies used by the app +pkg_dependencies="postgresql composer php-fpm php-curl php-mbstring php-imagick php-gd php-pgsql php-xml" + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= + + + # App package root directory should be the parent folder PKGDIR=$(cd ../; pwd) diff --git a/scripts/install b/scripts/install index 4d6a6ae..8a69808 100644 --- a/scripts/install +++ b/scripts/install @@ -28,99 +28,95 @@ language=$YNH_APP_ARG_LANGUAGE ssoenabled=$YNH_APP_ARG_SSOENABLED timezone=$(cat /etc/timezone) -### If it's 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 interests you 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 #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) - -# Check web path availability -ynh_webpath_available $domain $path_url # Register (book) web path -ynh_webpath_register $app $domain $path_url - +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_script_progression --message="Storing installation settings..." --weight=2 -# Save app settings -ynh_app_setting_set "$app" admin "$admin" -ynh_app_setting_set "$app" ssoenabled "$ssoenabled" -ynh_app_setting_set "$app" path "$path_url" - +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=admin --value=$admin +ynh_app_setting_set --app=$app --key=ssoenabled --value=$ssoenabled #================================================= # STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= +ynh_script_progression --message="Configuring firewall..." --weight=2 # Find a free port port=$(ynh_find_port 9537) +ynh_app_setting_set --app=$app --key=port --value=$port + # Open this port yunohost firewall allow --no-upnp TCP "$port" 2>&1 -ynh_app_setting_set "$app" port "$port" #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Installing dependencies..." --time --weight=1 # Install packages -ynh_install_app_dependencies php-gd php-curl php-imagick php-cli php-zmq +ynh_install_app_dependencies $pkg_dependencies #================================================= -# CREATE A MYSQL DATABASE +# CREATE A POSTGRESQL DATABASE #================================================= +ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2 -db_name=$(ynh_sanitize_dbid "$app") +db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name -ynh_app_setting_set "$app" db_name "$db_name" -ynh_mysql_setup_db "$db_user" "$db_name" +db_pwd=$(ynh_string_random --length=30) + +ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd + +ynh_psql_test_if_first_run +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Setting up source files..." --time --weight=1 -ynh_app_setting_set "$app" final_path "$final_path" - -ynh_setup_source "$final_path" +ynh_app_setting_set --app=$app --key=final_path --value=$final_path +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Configuring nginx web server..." --time --weight=1 # Create a dedicated nginx config ynh_add_nginx_config -ynh_replace_string "//ws/" "/ws/" "$finalnginxconf" # Avoid duplicate / - #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Configuring system user..." --time --weight=1 # Create a system user -ynh_system_user_create "$app" +ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Configuring php-fpm..." --time --weight=1 # Create a dedicated php-fpm config ynh_replace_string "YHTZ" "$timezone" ../conf/php-fpm.ini @@ -129,17 +125,20 @@ ynh_add_fpm_config #================================================= # SET CONFIGURATION FILE #================================================= +ynh_script_progression --message="Modifying a config file..." -# TODO: add checksum -cp ../conf/db.inc.php "$final_path/config/db.inc.php" +cp ../conf/db.example.inc.php $final_path/config/db.inc.php -ynh_replace_string "__DB_USER__" "$db_user" "$final_path/config/db.inc.php" -ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/config/db.inc.php" -ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/config/db.inc.php" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$final_path/config/db.inc.php" +ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/config/db.inc.php" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/config/db.inc.php" -## TODO: consider installation in a subpath -ynh_replace_string "'/ws/'" "'${path_url%/}/ws/'" \ - "$final_path/app/assets/js/movim_websocket.js" +ynh_store_file_checksum --file="$final_path/config/db.inc.php" + + + ## TODO: consider installation in a subpath + ynh_replace_string "'/ws/'" "'${path_url%/}/ws/'" \ + "$final_path/app/assets/js/movim_websocket.js" #================================================= # Install PHP dependencies using composer @@ -156,10 +155,11 @@ ynh_replace_string "'/ws/'" "'${path_url%/}/ws/'" \ #================================================= # SETUP SYSTEMD #================================================= +ynh_script_progression --message="Configuring a systemd service..." --weight=1 + +ynh_replace_string --match_string="__URL__" --replace_string="${domain}${path_url}" --target_file=../conf/systemd.service +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file=../conf/systemd.service -# Create a dedicated systemd config -ynh_replace_string "__URL__" "${domain}${path_url}" ../conf/systemd.service -ynh_replace_string "__PORT__" "${port}" ../conf/systemd.service ynh_add_systemd_config #=================================================