diff --git a/conf/.env b/conf/.env index b42f2a4..94f9605 100644 --- a/conf/.env +++ b/conf/.env @@ -18,7 +18,7 @@ HASH_SALT=ChangeMeBy20+KeyLength HASH_LENGTH=18 # The URL of your application. -APP_URL=http://localhost +APP_URL=https://__DOMAIN__ # Database information # To keep this information secure, we urge you to change the default password @@ -114,8 +114,8 @@ MFA_ENABLED=false # CLIENT ID and SECRET used for the official mobile application # This is to make sure that only the mobile application that you approve can # access the route to let your users sign in with their credentials -MOBILE_CLIENT_ID= -MOBILE_CLIENT_SECRET= +MOBILE_CLIENT_ID=__IDENTITY__ +MOBILE_CLIENT_SECRET=__KEY__ # Allow to access general statistics about your instance through a public API # call diff --git a/scripts/_common.sh b/scripts/_common.sh index 2b61c4d..9b942c6 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -109,7 +109,7 @@ ynh_install_php7 () { echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.list ynh_package_update - ynh_install_app_dependencies php7.1 php7.1-zip php7.1-fpm php7.1-mysql php7.1-xml php7.1-intl php7.1-mbstring php7.1-gd php7.1-curl php7.1-bcmath + ynh_install_app_dependencies php7.1 php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip php7.1-fpm php7.1-bcmath php7.1-intl php7.1-simplexml php7.1-dom php7.1-curl php7.1-gd sudo update-alternatives --install /usr/bin/php php /usr/bin/php5 70 } diff --git a/scripts/install b/scripts/install index 797c351..f14265f 100755 --- a/scripts/install +++ b/scripts/install @@ -123,7 +123,7 @@ email=$(ynh_user_get_info $admin 'mail') sudo cp ../conf/.env $final_path/.env db_name=$(ynh_sanitize_dbid $app) - +ynh_replace_string "__DOMAIN__" "$domain" "$final_path/.env" ynh_replace_string "random_key" "$random_key" "$final_path/.env" ynh_replace_string "yunouser" "$db_name" "$final_path/.env" ynh_replace_string "yunopass" "$db_pwd" "$final_path/.env" @@ -134,7 +134,16 @@ ynh_replace_string "language" "$language" "$final_path/.env" # setup application config -cd $final_path && sudo /usr/bin/php7.1 artisan monica:update --force +( cd $final_path && sudo /usr/bin/php7.1 artisan monica:update --force ) +( cd $final_path && sudo /usr/bin/php7.1 artisan passport:client --password -n > key.txt ) +mobile_id=$( cd $final_path && tail -2 test.txt | head -1 | cut -c 12- ) +mobile_keykey=$( cd $final_path && tail -1 key.txt | cut -c 16- ) +ynh_replace_string "__IDENTITY__" "$id" "$final_path/.env" +ynh_replace_string "__KEY__" "$key" "$final_path/.env" +ynh_app_setting_set $app mobile_id $mobile_id +ynh_app_setting_set $app mobile_key $mobile_key +(cd $final_path && rm -f key.txt) +(cd $final_path && sudo /usr/bin/php7.1 artisan monica:update --force) # create a cronjob to run the scheduler echo "* * * * * -u $app /usr/bin/php7.1 $final_path/artisan schedule:run" > /tmp/cron$app diff --git a/scripts/upgrade b/scripts/upgrade index bcdfd7a..f6abdee 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,7 +24,6 @@ db_name=$(ynh_app_setting_get $app db_name) db_pwd=$(ynh_app_setting_get $app mysqlpwd) language=$(ynh_app_setting_get $app language) random_key=$(ynh_app_setting_get $app random_key) - #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -95,7 +94,7 @@ ynh_system_user_create $app #================================================= # install new dependencies -ynh_install_app_dependencies php7.1 php7.1-zip php7.1-fpm php7.1-mysql php7.1-xml php7.1-intl php7.1-mbstring php7.1-gd php7.1-curl php7.1-bcmath +ynh_install_app_dependencies php7.1 php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip php7.1-fpm php7.1-bcmath php7.1-intl php7.1-simplexml php7.1-dom php7.1-curl php7.1-gd #================================================= # PHP-FPM 7.1 CONFIGURATION @@ -123,6 +122,20 @@ ynh_replace_string "language" "$language" "$final_path/.env" # Run monica update cd $final_path && sudo /usr/bin/php7.1 artisan monica:update --force +if [ -f $final_path/storage/oauth-private.key ]; then + mobile_id=$(ynh_app_setting_get $app mobile_id) + mobile_key=$(ynh_app_setting_get $app mobile_key) +else + ( cd $final_path && sudo /usr/bin/php7.1 artisan passport:client --password -n > key.txt ) + mobile_id=$( cd $final_path && tail -2 test.txt | head -1 | cut -c 12- ) + mobile_keykey=$( cd $final_path && tail -1 key.txt | cut -c 16- ) + ynh_replace_string "__IDENTITY__" "$id" "$final_path/.env" + ynh_replace_string "__KEY__" "$key" "$final_path/.env" + ynh_app_setting_set $app mobile_id $mobile_id + ynh_app_setting_set $app mobile_key $mobile_key + (cd $final_path && rm -f key.txt) + (cd $final_path && sudo /usr/bin/php7.1 artisan monica:update --force) +fi #================================================= # GENERIC FINALIZATION #=================================================