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

sqlite instead of mysql

This commit is contained in:
anmol26s 2018-07-01 02:58:55 +05:30
parent e1095a5812
commit 1071585b4a
6 changed files with 74 additions and 43 deletions

View file

@ -127,3 +127,61 @@ ynh_remove_php7 () {
sudo apt-key del 2048R/11A06851
ynh_remove_app_dependencies php7.2 php7.2-zip php7.2-fpm php7.2-mysql php7.2-xml php7.2-intl php7.2-mbstring php7.2-gd php7.2-curl php7.2-bcmath php7.2-opcache php7.2-sqlite3
}
# Send an email to inform the administrator
#
# usage: ynh_send_readme_to_admin app_message [recipients]
# | arg: app_message - The message to send to the administrator.
# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root
# example: "root admin@domain"
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
# example: "root admin@domain user1 user2"
ynh_send_readme_to_admin() {
local app_message="${1:-...No specific information...}"
local recipients="${2:-root}"
# Retrieve the email of users
find_mails () {
local list_mails="$1"
local mail
local recipients=" "
# Read each mail in argument
for mail in $list_mails
do
# Keep root or a real email address as it is
if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@"
then
recipients="$recipients $mail"
else
# But replace an user name without a domain after by its email
if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null)
then
recipients="$recipients $mail"
fi
fi
done
echo "$recipients"
}
recipients=$(find_mails "$recipients")
local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!"
local mail_message="This is an automated message from your beloved YunoHost server.
Specific information for the application $app.
$app_message
---
Automatic diagnosis data from YunoHost
$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
# Define binary to use for mail command
if [ -e /usr/bin/bsd-mailx ]
then
local mail_bin=/usr/bin/bsd-mailx
else
local mail_bin=/usr/bin/mail.mailutils
fi
# Send the email to the recipients
echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
}

View file

@ -29,7 +29,6 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain)
db_name=$(ynh_app_setting_get $app db_name)
#=================================================
# STANDARD BACKUP STEPS
@ -52,9 +51,3 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/php/7.2/fpm/pool.d/$app.conf"
ynh_backup "/etc/php/7.2/fpm/conf.d/20-$app.ini"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_mysql_dump_db "$db_name" > db.sql

View file

@ -24,6 +24,7 @@ domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
admin_pass=$(ynh_string_random 24)
random_key=$(ynh_string_random 32)
@ -72,15 +73,6 @@ ynh_app_setting_set $app random_key $random_key
ynh_install_php7
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
# If your app uses a MySQL database, you can use these lines to bootstrap
# a database, an associated user and save the password in app settings
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
ynh_mysql_setup_db $db_name $db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -130,14 +122,11 @@ sudo cp ../conf/.env $final_path/.env
# MODIFY A CONFIG FILE
#=================================================
ynh_replace_string "random_key" "$random_key" "$final_path/.env"
ynh_replace_string "db_user" "$db_name" "$final_path/.env"
ynh_replace_string "db_password" "$db_pwd" "$final_path/.env"
ynh_replace_string "db_name" "$db_name" "$final_path/.env"
init_composer $final_path
cd $final_path && sudo bin/console doctrine:schema:create
cd $final_path && sudo -u "$app" bin/console cache:warmup --env=prod
cd $final_path && sudo bin/console kimai:create-user "$admin" "$email" ROLE_SUPER_ADMIN
cd $final_path && sudo /usr/bin/php7.2 bin/console doctrine:schema:create
cd $final_path && sudo /usr/bin/php7.2 bin/console cache:warmup --env=prod
cd $final_path && sudo /usr/bin/php7.2 bin/console kimai:create-user "$admin" "$email" ROLE_SUPER_ADMIN "$admin_pass"
#=================================================
# SETUP APPLICATION
@ -179,3 +168,15 @@ if [ "$(lsb_release --codename --short)" == "jessie" ]; then
else
update-alternatives --set php /usr/bin/php7.0
fi
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
message=" $app was successfully installed :)
Please open https://$domain$path_url
The admin username is: $email
Here is the admin password: $admin_pass
If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/kimai2_ynh"
ynh_send_readme_to_admin "$message"

View file

@ -16,18 +16,12 @@ source /usr/share/yunohost/helpers
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
db_name=$(ynh_app_setting_get $app db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db $db_user $db_name
#=================================================
# REMOVE APP MAIN DIR

View file

@ -30,7 +30,6 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
@ -62,14 +61,6 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file "$final_path"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
ynh_mysql_setup_db $db_name $db_name $db_pwd
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
#=================================================
# RECREATE THE DEDICATED USER
#=================================================

View file

@ -20,7 +20,6 @@ path_url=$(ynh_app_setting_get $app path)
admin=$(ynh_app_setting_get $app admin)
is_public=$(ynh_app_setting_get $app is_public)
final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
random_key=$(ynh_app_setting_get $app random_key)
#=================================================
@ -36,11 +35,6 @@ elif [ "$is_public" = "No" ]; then
is_public=0
fi
# If db_name doesn't exist, create it
if [ -z $db_name ]; then
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
fi
# If final_path doesn't exist, create it
if [ -z $final_path ]; then