1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/joplin_ynh.git synced 2024-09-03 19:36:03 +02:00

Merge pull request #8 from fflorent/change-default-password

Many fixes
This commit is contained in:
eric_G 2024-04-24 14:11:01 +02:00 committed by GitHub
commit 5ee3ff7281
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 65 additions and 17 deletions

View file

@ -7,14 +7,8 @@ Type=simple
User=__APP__
Group=__APP__
Environment="APP_BASE_URL=https://__DOMAIN__"
Environment="APP_PORT=__PORT__"
Environment="DB_CLIENT=pg"
Environment="POSTGRES_PASSWORD=__DB_PWD__"
Environment="POSTGRES_DATABASE=__DB_NAME__"
Environment="POSTGRES_USER=__DB_USER__"
Environment="POSTGRES_PORT=5432"
Environment="POSTGRES_HOST=localhost"
Environment="__YNH_NODE_LOAD_PATH__"
EnvironmentFile=__INSTALL_DIR__/.env
WorkingDirectory=__INSTALL_DIR__/
ExecStart=/usr/bin/yarn __INSTALL_DIR__/packages/server start

View file

@ -1,4 +1,8 @@
Default credentials:
Now login to Joplin
- Url: https://__DOMAIN____PATH__
- Email: __ADMIN_MAIL__
- Password: __ADMIN_PASS__
Email: admin@localhost
Password: admin
Then you may change the default password at this page: https://__DOMAIN____PATH__/admin/users
Then download one of these Joplin apps and configure the synchronisation with your server: https://joplinapp.org/help/install/

View file

@ -38,6 +38,9 @@ ram.runtime = "50M"
type = "group"
default = "visitors"
[install.admin]
type = "user"
[resources]
[resources.sources]
@ -63,7 +66,7 @@ ram.runtime = "50M"
main.default = 22300
[resources.apt]
packages = "postgresql, postgresql-client"
packages = "postgresql, postgresql-client, python3-bcrypt"
extras.yarn.repo = "deb https://dl.yarnpkg.com/debian/ stable main"
extras.yarn.key = "https://dl.yarnpkg.com/debian/pubkey.gpg"
extras.yarn.packages = "yarn"

View file

@ -10,6 +10,11 @@ nodejs_version=18
# PERSONAL HELPERS
#=================================================
function bcrypt_password() {
echo -n "$1" | \
python3 -c "import bcrypt; import sys; print(bcrypt.hashpw(bytes(sys.stdin.read(), 'ascii'), bcrypt.gensalt(rounds=10)).decode('ascii'))"
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================

View file

@ -34,7 +34,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# BACKUP THE MYSQL DATABASE
# BACKUP THE PostgreSQL DATABASE
#=================================================
ynh_print_info --message="Backing up the PostgreSQL database..."

View file

@ -25,8 +25,12 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
ynh_change_url_nginx_config
ynh_use_nodejs
ynh_add_systemd_config
ynh_add_config --template=".env" --destination="$install_dir/.env"
#=================================================
# GENERIC FINALISATION
#=================================================

View file

@ -9,6 +9,14 @@
source _common.sh
source /usr/share/yunohost/helpers
admin_pass=$(ynh_string_random --length=24)
admin_mail=$(ynh_user_get_info --username=$admin --key="mail")
admin_name=$(ynh_user_get_info --username=$admin --key="fullname")
# Store these values even if we don't need them, so they are printed in the post-install message
ynh_app_setting_set --app=$app --key=admin_pass --value=$admin_pass
ynh_app_setting_set --app=$app --key=admin_mail --value=$admin_mail
#=================================================
# INSTALL DEPENDENCIES
#=================================================
@ -57,11 +65,12 @@ chown $app:$app "$install_dir/.env"
#=================================================
# INSTALL JOPLIN
#=================================================
ynh_script_progression --message="Installing $app..." --weight=10
ynh_script_progression --message="Building $app..." --weight=10
pushd $install_dir
pushd $install_dir/packages/server
ynh_use_nodejs
sudo -u $app env $ynh_node_load_PATH BUILD_SEQUENCIAL=1 yarn install --inline-builds
sudo -u $app env $ynh_node_load_PATH yarn build
sudo -u $app env $ynh_node_load_PATH yarn cache clean
ynh_secure_remove .yarn/berry
popd
@ -74,7 +83,20 @@ popd
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Starting services..."
#=================================================
# CHANGING DEFAULT ADMIN PASSWORD
#=================================================
ynh_script_progression --message="Changing default admin password..." --weight=1
hashed_pwd=$(bcrypt_password "$admin_pass")
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" <<< "
UPDATE users
SET password='$hashed_pwd', email='$admin_mail', full_name='$admin_name'
WHERE email='admin@localhost'
"
#=================================================
# END OF SCRIPT

View file

@ -20,7 +20,7 @@ ynh_restore_file --origin_path="$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# RESTORE THE MYSQL DATABASE
# RESTORE THE PostgreSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1

View file

@ -42,6 +42,22 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=5
# Install Nodejs
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# BUILD
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Building $app..." --weight=10
pushd $install_dir/packages/server
ynh_use_nodejs
sudo -u $app env $ynh_node_load_PATH BUILD_SEQUENCIAL=1 yarn install --inline-builds
sudo -u $app env $ynh_node_load_PATH yarn build
sudo -u $app env $ynh_node_load_PATH yarn cache clean
ynh_secure_remove .yarn/berry
popd
fi
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================