diff --git a/README.md b/README.md index 1a16bd2..db42954 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Shiori is a simple bookmarks manager written in Go language. Intended as a simpl ## Disclaimers / important information -First connection credentials are: +The default account is `shiori` with password `gopher`. It is removed once another 'owner' account is created. - username: `shiori` - password: `gopher` diff --git a/README_fr.md b/README_fr.md index d46a8b2..58c40b5 100644 --- a/README_fr.md +++ b/README_fr.md @@ -36,7 +36,7 @@ Shiori is a simple bookmarks manager written in Go language. Intended as a simpl ## Avertissements / informations importantes -First connection credentials are: +The default account is `shiori` with password `gopher`. It is removed once another 'owner' account is created. - username: `shiori` - password: `gopher` diff --git a/conf/nginx.conf b/conf/nginx.conf index 96ccc0c..d601a3a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -7,9 +7,10 @@ location / { proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; - proxy_set_header Connection ''; + proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/conf/systemd.service b/conf/systemd.service index 2dc65e8..eeb2d71 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -9,8 +9,8 @@ User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/ ExecStart=__FINALPATH__/shiori serve --port __PORT__ -StandardOutput=append:/var/log/__APP__/__APP__.log -StandardError=inherit +Restart=always +Environment="SHIORI_DIR=__DATADIR__" [Install] WantedBy=multi-user.target diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index a792612..11a57fd 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -1,4 +1,4 @@ -First connection credentials are: +The default account is `shiori` with password `gopher`. It is removed once another 'owner' account is created. - username: `shiori` - password: `gopher` diff --git a/scripts/backup b/scripts/backup index cbcef80..bf59418 100755 --- a/scripts/backup +++ b/scripts/backup @@ -26,7 +26,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -59,13 +59,6 @@ ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/systemd/system/$app.service" -#================================================= -# BACKUP THE MYSQL DATABASE -#================================================= -ynh_print_info --message="Backing up the MySQL database..." - -ynh_mysql_dump_db --database="$db_name" > db.sql - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index ad2bd8e..4b42d76 100755 --- a/scripts/install +++ b/scripts/install @@ -64,16 +64,6 @@ ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user ynh_system_user_create --username=$app --home_dir="$final_path" -#================================================= -# CREATE A MYSQL DATABASE -#================================================= -ynh_script_progression --message="Creating a MySQL database..." --weight=2 - -db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -97,14 +87,18 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 ynh_add_nginx_config #================================================= -# ADD A CONFIGURATION +# CREATE DATA DIRECTORY #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression --message="Creating a data directory..." --weight=1 -ynh_add_config --template="../conf/.env" --destination="$final_path/.env" +datadir=/home/yunohost.app/$app +ynh_app_setting_set --app=$app --key=datadir --value=$datadir -chmod 400 "$final_path/.env" -chown $app:$app "$final_path/.env" +mkdir -p $datadir + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" #================================================= # SETUP SYSTEMD @@ -155,8 +149,6 @@ then ynh_permission_update --permission="main" --add="visitors" fi -ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" - #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/remove b/scripts/remove index 2a50a54..1501f3e 100755 --- a/scripts/remove +++ b/scripts/remove @@ -17,9 +17,8 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # STANDARD REMOVE @@ -53,9 +52,9 @@ ynh_secure_remove --file="/var/log/$app" ynh_remove_logrotate #================================================= -# REMOVE THE MYSQL DATABASE +# REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing the MySQL database..." --weight=1 +ynh_script_progression --message="Removing dependencies..." --weight=1 # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name @@ -68,6 +67,17 @@ ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely ynh_secure_remove --file="$final_path" +#================================================= +# REMOVE DATA DIR +#================================================= + +# Remove the data directory if --purge option is used +if [ "${YNH_APP_PURGE:-0}" -eq 1 ] +then + ynh_script_progression --message="Removing app data directory..." --weight=1 + ynh_secure_remove --file="$datadir" +fi + #================================================= # REMOVE NGINX CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 33835b4..61c4223 100755 --- a/scripts/restore +++ b/scripts/restore @@ -27,15 +27,14 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=1 -test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " +test ! -d $final_path || ynh_die --message="There is already a directory: $final_path" #================================================= # STANDARD RESTORATION STEPS @@ -67,13 +66,27 @@ chown -R $app:www-data "$final_path" chmod +x "$final_path/shiori" #================================================= -# RESTORE THE MYSQL DATABASE +# RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=1 +ynh_script_progression --message="Restoring the data directory..." --weight=1 -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_restore_file --origin_path="$datadir" --not_mandatory + +mkdir -p $datadir + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=1 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index 9e72e70..9b3e58f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,7 +20,8 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) port=$(ynh_app_setting_get --app=$app --key=port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) +port=$(ynh_app_setting_get --app=$app --key=port) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK VERSION