Bob Mottram 8 anni fa
parent
commit
efdd084e42
1 ha cambiato i file con 531 aggiunte e 0 eliminazioni
  1. 531
    0
      src/freedombone-app-koel

+ 531
- 0
src/freedombone-app-koel Vedi File

@@ -0,0 +1,531 @@
1
+#!/bin/bash
2
+#
3
+# .---.                  .              .
4
+# |                      |              |
5
+# |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-.
6
+# |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-'
7
+# '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --'
8
+#
9
+#                    Freedom in the Cloud
10
+#
11
+# koel application
12
+# https://gist.github.com/bplower/613a99156d603abac083
13
+#
14
+# License
15
+# =======
16
+#
17
+# Copyright (C) 2017 Bob Mottram <bob@freedombone.net>
18
+#
19
+# This program is free software: you can redistribute it and/or modify
20
+# it under the terms of the GNU Affero General Public License as published by
21
+# the Free Software Foundation, either version 3 of the License, or
22
+# (at your option) any later version.
23
+#
24
+# This program is distributed in the hope that it will be useful,
25
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
26
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
+# GNU Affero General Public License for more details.
28
+#
29
+# You should have received a copy of the GNU Affero General Public License
30
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
31
+
32
+VARIANTS='full full-vim media'
33
+
34
+IN_DEFAULT_INSTALL=0
35
+SHOW_ON_ABOUT=1
36
+
37
+KOEL_DOMAIN_NAME=
38
+KOEL_CODE=
39
+KOEL_ONION_PORT=8118
40
+KOEL_REPO="https://github.com/phanan/koel"
41
+KOEL_COMMIT='70464a8977b1058f3bd0a4ec77877fe7894d8d84'
42
+KOEL_ADMIN_PASSWORD=
43
+
44
+koel_variables=(ONION_ONLY
45
+                KOEL_DOMAIN_NAME
46
+                KOEL_CODE
47
+                DDNS_PROVIDER
48
+                MY_EMAIL_ADDRESS
49
+                MY_USERNAME)
50
+
51
+function remove_user_koel {
52
+    remove_username="$1"
53
+
54
+    ${PROJECT_NAME}-pass -u $remove_username --rmapp koel
55
+}
56
+
57
+function add_user_koel {
58
+    new_username="$1"
59
+    new_user_password="$2"
60
+
61
+    ${PROJECT_NAME}-pass -u $new_username -a koel -p "$new_user_password"
62
+    echo '0'
63
+}
64
+
65
+function install_interactive_koel {
66
+    if [ ! $ONION_ONLY ]; then
67
+        ONION_ONLY='no'
68
+    fi
69
+
70
+    if [[ $ONION_ONLY != "no" ]]; then
71
+        KOEL_DOMAIN_NAME='koel.local'
72
+    else
73
+        KOEL_DETAILS_COMPLETE=
74
+        while [ ! $KOEL_DETAILS_COMPLETE ]
75
+        do
76
+            data=$(tempfile 2>/dev/null)
77
+            trap "rm -f $data" 0 1 2 5 15
78
+            if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
79
+                dialog --backtitle $"Freedombone Configuration" \
80
+                       --title $"Koel Configuration" \
81
+                       --form $"\nPlease enter your Koel details. The background image URL can be left blank.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 16 65 3 \
82
+                       $"Domain:" 1 1 "$(grep 'KOEL_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
83
+                       $"Code:" 2 1 "$(grep 'KOEL_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 25 33 255 \
84
+                       2> $data
85
+            else
86
+                dialog --backtitle $"Freedombone Configuration" \
87
+                       --title $"Koel Configuration" \
88
+                       --form $"\nPlease enter your Koel details. The background image URL can be left blank.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 16 65 3 \
89
+                       $"Domain:" 1 1 "$(grep 'KOEL_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
90
+                       2> $data
91
+            fi
92
+            sel=$?
93
+            case $sel in
94
+                1) exit 1;;
95
+                255) exit 1;;
96
+            esac
97
+            KOEL_DOMAIN_NAME=$(cat $data | sed -n 1p)
98
+            if [ $KOEL_DOMAIN_NAME ]; then
99
+                if [[ $KOEL_DOMAIN_NAME == "$HUBZILLA_DOMAIN_NAME" ]]; then
100
+                    KOEL_DOMAIN_NAME=""
101
+                fi
102
+                TEST_DOMAIN_NAME=$KOEL_DOMAIN_NAME
103
+                validate_domain_name
104
+                if [[ $TEST_DOMAIN_NAME != $KOEL_DOMAIN_NAME ]]; then
105
+                    KOEL_DOMAIN_NAME=
106
+                    dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
107
+                else
108
+                    if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
109
+                        KOEL_CODE=$(cat $data | sed -n 2p)
110
+                        validate_freedns_code "$KOEL_CODE"
111
+                        if [ ! $VALID_CODE ]; then
112
+                            KOEL_DOMAIN_NAME=
113
+                        fi
114
+                    fi
115
+                fi
116
+            fi
117
+            if [ $KOEL_DOMAIN_NAME ]; then
118
+                KOEL_DETAILS_COMPLETE="yes"
119
+            fi
120
+        done
121
+
122
+        # save the results in the config file
123
+        write_config_param "KOEL_CODE" "$KOEL_CODE"
124
+    fi
125
+    write_config_param "KOEL_DOMAIN_NAME" "$KOEL_DOMAIN_NAME"
126
+    APP_INSTALLED=1
127
+}
128
+
129
+function change_password_koel {
130
+    curr_username="$1"
131
+    new_user_password="$2"
132
+
133
+    read_config_param 'KOEL_DOMAIN_NAME'
134
+
135
+    ${PROJECT_NAME}-pass -u "$curr_username" -a koel -p "$new_user_password"
136
+}
137
+
138
+function koel_create_database {
139
+    if [ -f $IMAGE_PASSWORD_FILE ]; then
140
+        KOEL_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
141
+    else
142
+        if [ ! $KOEL_ADMIN_PASSWORD ]; then
143
+            KOEL_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
144
+        fi
145
+    fi
146
+    if [ ! $KOEL_ADMIN_PASSWORD ]; then
147
+        return
148
+    fi
149
+
150
+    function_check create_database
151
+    create_database koel "$KOEL_ADMIN_PASSWORD" $MY_USERNAME
152
+}
153
+
154
+function reconfigure_koel {
155
+    echo -n ''
156
+}
157
+
158
+function configure_interactive_koel {
159
+    echo -n ''
160
+}
161
+
162
+function upgrade_koel {
163
+    if grep -q "koel domain" $COMPLETION_FILE; then
164
+        KOEL_DOMAIN_NAME=$(get_completion_param "koel domain")
165
+    fi
166
+
167
+    # update to the next commit
168
+    function_check set_repo_commit
169
+    set_repo_commit /var/www/$KOEL_DOMAIN_NAME/htdocs "koel commit" "$KOEL_COMMIT" $KOEL_REPO
170
+
171
+    chown -R www-data:www-data /var/www/${KOEL_DOMAIN_NAME}/htdocs
172
+}
173
+
174
+
175
+function backup_local_koel {
176
+    KOEL_DOMAIN_NAME='koel'
177
+    if grep -q "koel domain" $COMPLETION_FILE; then
178
+        KOEL_DOMAIN_NAME=$(get_completion_param "koel domain")
179
+    fi
180
+
181
+    source_directory=/var/www/${KOEL_DOMAIN_NAME}/htdocs
182
+    if [ -d $source_directory ]; then
183
+        dest_directory=koel
184
+        function_check suspend_site
185
+        suspend_site ${KOEL_DOMAIN_NAME}
186
+
187
+        function_check backup_directory_to_usb
188
+        backup_directory_to_usb $source_directory $dest_directory
189
+
190
+        function_check backup_database_to_usb
191
+        backup_database_to_usb koel
192
+
193
+        function_check restart_site
194
+        restart_site
195
+    fi
196
+}
197
+
198
+function restore_local_koel {
199
+    if ! grep -q "koel domain" $COMPLETION_FILE; then
200
+        return
201
+    fi
202
+    KOEL_DOMAIN_NAME=$(get_completion_param "koel domain")
203
+    if [ $KOEL_DOMAIN_NAME ]; then
204
+        echo $"Restoring koel"
205
+        temp_restore_dir=/root/tempkoel
206
+        koel_dir=/var/www/${KOEL_DOMAIN_NAME}/htdocs
207
+
208
+        function_check koel_create_database
209
+        koel_create_database
210
+
211
+        restore_database koel ${KOEL_DOMAIN_NAME}
212
+        if [ -d $temp_restore_dir ]; then
213
+            rm -rf $temp_restore_dir
214
+        fi
215
+    fi
216
+}
217
+
218
+function backup_remote_koel {
219
+    if grep -q "koel domain" $COMPLETION_FILE; then
220
+        KOEL_DOMAIN_NAME=$(get_completion_param "koel domain")
221
+        temp_backup_dir=/var/www/${KOEL_DOMAIN_NAME}/htdocs
222
+        if [ -d $temp_backup_dir ]; then
223
+            function_check suspend_site
224
+            suspend_site ${KOEL_DOMAIN_NAME}
225
+
226
+            function_check backup_database_to_friend
227
+            backup_database_to_friend koel
228
+
229
+            echo $"Backing up Koel installation"
230
+
231
+            function_check backup_directory_to_friend
232
+            backup_directory_to_friend $temp_backup_dir koel
233
+
234
+            function_check restart_site
235
+            restart_site
236
+        else
237
+            echo $"koel domain specified but not found in ${temp_backup_dir}"
238
+        fi
239
+    fi
240
+}
241
+
242
+function restore_remote_koel {
243
+    if grep -q "koel domain" $COMPLETION_FILE; then
244
+        echo $"Restoring koel"
245
+        KOEL_DOMAIN_NAME=$(get_completion_param "koel domain")
246
+
247
+        # stop the daemons
248
+        cd /var/www/${KOEL_DOMAIN_NAME}/htdocs
249
+        su -c "sh scripts/stopdaemons.sh" -s /bin/sh www-data
250
+
251
+        function_check koel_create_database
252
+        koel_create_database
253
+
254
+        function_check restore_database_from_friend
255
+        restore_database_from_friend koel ${KOEL_DOMAIN_NAME}
256
+        if [ -d /root/tempkoel ]; then
257
+            rm -rf /root/tempkoel
258
+        fi
259
+
260
+        # start the daemons
261
+        cd /var/www/${KOEL_DOMAIN_NAME}/htdocs
262
+        su -c "sh scripts/startdaemons.sh" -s /bin/sh www-data
263
+        echo $"Restore of koel complete"
264
+    fi
265
+}
266
+
267
+function remove_koel {
268
+    if [ ${#KOEL_DOMAIN_NAME} -eq 0 ]; then
269
+        return
270
+    fi
271
+    function_check remove_nodejs
272
+    remove_nodejs koel
273
+
274
+    read_config_param "KOEL_DOMAIN_NAME"
275
+    read_config_param "MY_USERNAME"
276
+    echo "Removing $KOEL_DOMAIN_NAME"
277
+    nginx_dissite $KOEL_DOMAIN_NAME
278
+    remove_certs $KOEL_DOMAIN_NAME
279
+
280
+    if [ -d /var/www/$KOEL_DOMAIN_NAME ]; then
281
+        rm -rf /var/www/$KOEL_DOMAIN_NAME
282
+    fi
283
+    if [ -f /etc/nginx/sites-available/$KOEL_DOMAIN_NAME ]; then
284
+        rm /etc/nginx/sites-available/$KOEL_DOMAIN_NAME
285
+    fi
286
+    function_check drop_database
287
+    drop_database koel
288
+    function_check remove_onion_service
289
+    remove_onion_service koel ${KOEL_ONION_PORT}
290
+    if grep -q "koel" /etc/crontab; then
291
+        sed -i "/koel/d" /etc/crontab
292
+    fi
293
+    remove_app koel
294
+    remove_completion_param install_koel
295
+    sed -i '/koel/d' $COMPLETION_FILE
296
+    remove_backup_database_local koel
297
+
298
+    sed -i '/koel-firewall/d' /etc/crontab
299
+
300
+    function_check remove_ddns_domain
301
+    remove_ddns_domain $KOEL_DOMAIN_NAME
302
+}
303
+
304
+function install_koel_main {
305
+    if [ ! $KOEL_DOMAIN_NAME ]; then
306
+        echo $'No domain name was given for koel'
307
+        exit 7359
308
+    fi
309
+
310
+    if [[ $(app_is_installed koel_main) == "1" ]]; then
311
+        return
312
+    fi
313
+
314
+    koel_hourly_script koel $KOEL_DOMAIN_NAME
315
+
316
+    function_check install_mariadb
317
+    install_mariadb
318
+
319
+    function_check get_mariadb_password
320
+    get_mariadb_password
321
+
322
+    function_check repair_databases_script
323
+    repair_databases_script
324
+
325
+    apt-get -yq install php-gettext php5-curl php5-gd php5-mysql git curl php-xml-parser
326
+    apt-get -yq install php5-memcached php5-intl exiftool
327
+
328
+    if [ ! -d /var/www/$KOEL_DOMAIN_NAME ]; then
329
+        mkdir /var/www/$KOEL_DOMAIN_NAME
330
+    fi
331
+    if [ ! -d /var/www/$KOEL_DOMAIN_NAME/htdocs ]; then
332
+        function_check git_clone
333
+        git_clone $KOEL_REPO /var/www/$KOEL_DOMAIN_NAME/htdocs
334
+        if [ ! -d /var/www/$KOEL_DOMAIN_NAME/htdocs ]; then
335
+            echo $'Unable to clone koel repo'
336
+            exit 365735
337
+        fi
338
+    fi
339
+
340
+    cd /var/www/$KOEL_DOMAIN_NAME/htdocs
341
+    git checkout $KOEL_COMMIT -b $KOEL_COMMIT
342
+    set_completion_param "koel commit" "$KOEL_COMMIT"
343
+
344
+    chown -R www-data:www-data /var/www/$KOEL_DOMAIN_NAME/htdocs
345
+
346
+    function_check koel_create_database
347
+    koel_create_database
348
+
349
+    function_check add_ddns_domain
350
+    add_ddns_domain $KOEL_DOMAIN_NAME
351
+
352
+    koel_nginx_site=/etc/nginx/sites-available/$KOEL_DOMAIN_NAME
353
+    if [[ $ONION_ONLY == "no" ]]; then
354
+        function_check nginx_http_redirect
355
+        nginx_http_redirect $KOEL_DOMAIN_NAME "index index.php"
356
+        echo 'server {' >> $koel_nginx_site
357
+        echo '  listen 443 ssl;' >> $koel_nginx_site
358
+        echo '  listen [::]:443 ssl;' >> $koel_nginx_site
359
+        echo "  server_name $KOEL_DOMAIN_NAME;" >> $koel_nginx_site
360
+        echo '' >> $koel_nginx_site
361
+        function_check nginx_compress
362
+        nginx_compress $KOEL_DOMAIN_NAME
363
+        echo '' >> $koel_nginx_site
364
+        echo '  # Security' >> $koel_nginx_site
365
+        function_check nginx_ssl
366
+        nginx_ssl $KOEL_DOMAIN_NAME
367
+
368
+        function_check nginx_disable_sniffing
369
+        nginx_disable_sniffing $KOEL_DOMAIN_NAME
370
+
371
+        echo '  add_header Strict-Transport-Security max-age=15768000;' >> $koel_nginx_site
372
+        echo '' >> $koel_nginx_site
373
+        echo '  # Logs' >> $koel_nginx_site
374
+        echo '  access_log /dev/null;' >> $koel_nginx_site
375
+        echo '  error_log /dev/null;' >> $koel_nginx_site
376
+        echo '' >> $koel_nginx_site
377
+        echo '  # Root' >> $koel_nginx_site
378
+        echo "  root /var/www/$KOEL_DOMAIN_NAME/htdocs;" >> $koel_nginx_site
379
+        echo '' >> $koel_nginx_site
380
+        echo '  # Index' >> $koel_nginx_site
381
+        echo '  index index.php;' >> $koel_nginx_site
382
+        echo '' >> $koel_nginx_site
383
+        echo '  # PHP' >> $koel_nginx_site
384
+        echo '  location ~ \.php {' >> $koel_nginx_site
385
+        echo '    include snippets/fastcgi-php.conf;' >> $koel_nginx_site
386
+        echo '    fastcgi_pass unix:/var/run/php5-fpm.sock;' >> $koel_nginx_site
387
+        echo '  }' >> $koel_nginx_site
388
+        echo '' >> $koel_nginx_site
389
+        echo '  # Location' >> $koel_nginx_site
390
+        echo '  location / {' >> $koel_nginx_site
391
+        function_check nginx_limits
392
+        nginx_limits $KOEL_DOMAIN_NAME '15m'
393
+        echo '    try_files $uri $uri/ @koel;' >> $koel_nginx_site
394
+        echo '  }' >> $koel_nginx_site
395
+        echo '' >> $koel_nginx_site
396
+        echo '  # Fancy URLs' >> $koel_nginx_site
397
+        echo '  location @koel {' >> $koel_nginx_site
398
+        echo '    rewrite ^(.*)$ /index.php?p=$1 last;' >> $koel_nginx_site
399
+        echo '  }' >> $koel_nginx_site
400
+        echo '' >> $koel_nginx_site
401
+        echo '  # Restrict access that is unnecessary anyway' >> $koel_nginx_site
402
+        echo '  location ~ /\.(ht|git) {' >> $koel_nginx_site
403
+        echo '    deny all;' >> $koel_nginx_site
404
+        echo '  }' >> $koel_nginx_site
405
+        echo '' >> $koel_nginx_site
406
+        echo '}' >> $koel_nginx_site
407
+    else
408
+        echo -n '' > $koel_nginx_site
409
+    fi
410
+    echo 'server {' >> $koel_nginx_site
411
+    echo "    listen 127.0.0.1:$KOEL_ONION_PORT default_server;" >> $koel_nginx_site
412
+    echo "    server_name $KOEL_DOMAIN_NAME;" >> $koel_nginx_site
413
+    echo '' >> $koel_nginx_site
414
+    function_check nginx_compress
415
+    nginx_compress $KOEL_DOMAIN_NAME
416
+    echo '' >> $koel_nginx_site
417
+    function_check nginx_disable_sniffing
418
+    nginx_disable_sniffing $KOEL_DOMAIN_NAME
419
+    echo '' >> $koel_nginx_site
420
+    echo '  # Logs' >> $koel_nginx_site
421
+    echo '  access_log /dev/null;' >> $koel_nginx_site
422
+    echo '  error_log /dev/null;' >> $koel_nginx_site
423
+    echo '' >> $koel_nginx_site
424
+    echo '  # Root' >> $koel_nginx_site
425
+    echo "  root /var/www/$KOEL_DOMAIN_NAME/htdocs;" >> $koel_nginx_site
426
+    echo '' >> $koel_nginx_site
427
+    echo '  # Index' >> $koel_nginx_site
428
+    echo '  index index.php;' >> $koel_nginx_site
429
+    echo '' >> $koel_nginx_site
430
+    echo '  # PHP' >> $koel_nginx_site
431
+    echo '  location ~ \.php {' >> $koel_nginx_site
432
+    echo '    include snippets/fastcgi-php.conf;' >> $koel_nginx_site
433
+    echo '    fastcgi_pass unix:/var/run/php5-fpm.sock;' >> $koel_nginx_site
434
+    echo '  }' >> $koel_nginx_site
435
+    echo '' >> $koel_nginx_site
436
+    echo '  # Location' >> $koel_nginx_site
437
+    echo '  location / {' >> $koel_nginx_site
438
+    function_check nginx_limits
439
+    nginx_limits $KOEL_DOMAIN_NAME '15m'
440
+    echo '    try_files $uri $uri/ @koel;' >> $koel_nginx_site
441
+    echo '  }' >> $koel_nginx_site
442
+    echo '' >> $koel_nginx_site
443
+    echo '  # Fancy URLs' >> $koel_nginx_site
444
+    echo '  location @koel {' >> $koel_nginx_site
445
+    echo '    rewrite ^(.*)$ /index.php?p=$1 last;' >> $koel_nginx_site
446
+    echo '  }' >> $koel_nginx_site
447
+    echo '' >> $koel_nginx_site
448
+    echo '  # Restrict access that is unnecessary anyway' >> $koel_nginx_site
449
+    echo '  location ~ /\.(ht|git) {' >> $koel_nginx_site
450
+    echo '    deny all;' >> $koel_nginx_site
451
+    echo '  }' >> $koel_nginx_site
452
+    echo '' >> $koel_nginx_site
453
+    echo '}' >> $koel_nginx_site
454
+
455
+    function_check configure_php
456
+    configure_php
457
+
458
+    function_check create_site_certificate
459
+    create_site_certificate $KOEL_DOMAIN_NAME 'yes'
460
+
461
+    # Ensure that the database gets backed up locally, if remote
462
+    # backups are not being used
463
+    function_check backup_databases_script_header
464
+    backup_databases_script_header
465
+
466
+    function_check backup_database_local
467
+    backup_database_local koel
468
+
469
+    function_check nginx_ensite
470
+    nginx_ensite $KOEL_DOMAIN_NAME
471
+
472
+    KOEL_ONION_HOSTNAME=$(add_onion_service koel 80 ${KOEL_ONION_PORT})
473
+
474
+    KOEL_SERVER=${KOEL_DOMAIN_NAME}
475
+    if [[ $ONION_ONLY != 'no' ]]; then
476
+        KOEL_SERVER=${KOEL_ONION_HOSTNAME}
477
+    fi
478
+
479
+    systemctl restart php5-fpm
480
+    systemctl restart nginx
481
+
482
+    ${PROJECT_NAME}-pass -u $MY_USERNAME -a koel -p "$KOEL_ADMIN_PASSWORD"
483
+
484
+    set_completion_param "koel domain" "$KOEL_DOMAIN_NAME"
485
+
486
+    install_completed koel_main
487
+}
488
+
489
+function install_koel {
490
+    if [ ! $ONION_ONLY ]; then
491
+        ONION_ONLY='no'
492
+    fi
493
+
494
+    function_check install_nodejs
495
+    install_nodejs koel
496
+
497
+    install_koel_main
498
+
499
+    cd /var/www/$KOEL_DOMAIN_NAME/htdocs
500
+
501
+    # curl -sS https://getcomposer.org/installer | php
502
+    if [ -f ~/freedombone/image_build/composer_install ]; then
503
+        cat ~/freedombone/image_build/composer_install | php
504
+    else
505
+        if [ -f /home/$MY_USERNAME/freedombone/image_build/composer_install ]; then
506
+            cat /home/$MY_USERNAME/freedombone/image_build/composer_install | php
507
+        fi
508
+    fi
509
+    npm install
510
+    php composer install
511
+
512
+    cp .env.example .env
513
+    sed -i "s/ADMIN_EMAIL=.*/ADMIN_EMAIL=$MY_EMAIL_ADDRESS/g" .env
514
+    sed -i "s/ADMIN_NAME=.*/ADMIN_NAME=$MY_USERNAME/g" .env
515
+    sed -i "s/ADMIN_PASSWORD=.*/ADMIN_PASSWORD=$KOEL_ADMIN_PASSWORD/g" .env
516
+    sed -i 's/DB_CONNECTION=.*/DB_CONNECTION=mysql/g' .env
517
+    sed -i 's/DB_HOST=.*/DB_HOST=127.0.0.1/g' .env
518
+    sed -i 's/DB_DATABASE=.*/DB_DATABASE=koel/g' .env
519
+    sed -i 's/DB_USERNAME=.*/DB_USERNAME=root/g' .env
520
+    sed -i "s/DB_PASSWORD=secret/DB_PASSWORD=$MARIADB_PASSWORD/g" .env
521
+
522
+    php artisan koel:init
523
+    php artisan serve
524
+
525
+    chown -R www-data:www-data /var/www/$KOEL_DOMAIN_NAME/htdocs
526
+    systemctl restart nginx
527
+
528
+    APP_INSTALLED=1
529
+}
530
+
531
+# NOTE: deliberately there is no "exit 0"