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

78 lines
2.7 KiB
Text
Raw Normal View History

2023-05-06 14:23:47 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
2023-05-06 17:34:55 +02:00
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
admin_fullname=$(ynh_user_get_info --username="$admin" --key=fullname)
2023-05-06 14:23:47 +02:00
#=================================================
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository.
### `ynh_setup_source` use the file conf/app.src
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
# $install_dir will automatically be initialized with some decent
# permission by default ... however, you may need to recursively reapply
# ownership to all files such as after the ynh_setup_source step
chown -R $app:www-data "$install_dir"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated PHP-FPM config using the conf/php-fpm.conf or conf/extra_php-fpm.conf
ynh_add_fpm_config
# Create a dedicated NGINX config using the conf/nginx.conf template
ynh_add_nginx_config
#=================================================
2023-05-06 17:34:55 +02:00
# Automated installation process
2023-05-06 14:23:47 +02:00
#=================================================
2023-05-06 17:34:55 +02:00
# Dirty trick to bypass the manual installation process
# Use Laravel CLI to create the admin user as the installation proccess would do
# See https://github.com/LinkStackOrg/LinkStack/blob/5dbb2b182d58b79149e02ffedcd3f63ba916b3c9/app/Http/Controllers/InstallerController.php#L68-L78
2023-05-06 14:23:47 +02:00
2023-05-06 17:34:55 +02:00
pushd $install_dir
php8.1 artisan tinker --execute="""
use App\Models\User;
2023-05-06 14:23:47 +02:00
2023-05-06 17:34:55 +02:00
User::create([
'name' => $admin_fullname,
'email' => $admin_mail,
'email_verified_at' => '0001-01-01 00:00:00',
'password' => Hash::make($password),
'littlelink_name' => $admin,
'littlelink_description' => 'admin page',
'block' => 'no',
]);
2023-05-06 14:23:47 +02:00
2023-05-06 17:34:55 +02:00
User::where('id', '1')->update(['role' => 'admin']);
"""
popd
# End of installation
ynh_secure_remove $install_dir/INSTALLING
2023-05-06 14:23:47 +02:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last