浏览代码

Set database password on koel restore

Bob Mottram 7 年前
父节点
当前提交
86d1c1a7d3
共有 1 个文件被更改,包括 19 次插入8 次删除
  1. 19
    8
      src/freedombone-app-koel

+ 19
- 8
src/freedombone-app-koel 查看文件

@@ -323,7 +323,7 @@ function backup_local_koel {
323 323
 
324 324
     source_directory=/var/www/${KOEL_DOMAIN_NAME}/htdocs
325 325
     if [ -d $source_directory ]; then
326
-        systemctl stop koal
326
+        systemctl stop koel
327 327
 
328 328
         dest_directory=koel
329 329
         function_check suspend_site
@@ -338,7 +338,7 @@ function backup_local_koel {
338 338
         function_check restart_site
339 339
         restart_site
340 340
 
341
-        systemctl start koal
341
+        systemctl start koel
342 342
     fi
343 343
 }
344 344
 
@@ -349,7 +349,7 @@ function restore_local_koel {
349 349
     KOEL_DOMAIN_NAME=$(get_completion_param "koel domain")
350 350
     if [ $KOEL_DOMAIN_NAME ]; then
351 351
         echo $"Restoring koel"
352
-        systemctl stop koal
352
+        systemctl stop koel
353 353
 
354 354
         temp_restore_dir=/root/tempkoel
355 355
         koel_dir=/var/www/${KOEL_DOMAIN_NAME}/htdocs
@@ -361,7 +361,13 @@ function restore_local_koel {
361 361
         if [ -d $temp_restore_dir ]; then
362 362
             rm -rf $temp_restore_dir
363 363
         fi
364
-        systemctl start koal
364
+
365
+        MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
366
+        cd /var/www/$KOEL_DOMAIN_NAME/htdocs
367
+        sed -i "s|DB_PASSWORD=.*|DB_PASSWORD=$MARIADB_PASSWORD|g" .env
368
+        MARIADB_PASSWORD=
369
+
370
+        systemctl start koel
365 371
     fi
366 372
 }
367 373
 
@@ -370,7 +376,7 @@ function backup_remote_koel {
370 376
         KOEL_DOMAIN_NAME=$(get_completion_param "koel domain")
371 377
         temp_backup_dir=/var/www/${KOEL_DOMAIN_NAME}/htdocs
372 378
         if [ -d $temp_backup_dir ]; then
373
-            systemctl stop koal
379
+            systemctl stop koel
374 380
 
375 381
             function_check suspend_site
376 382
             suspend_site ${KOEL_DOMAIN_NAME}
@@ -386,7 +392,7 @@ function backup_remote_koel {
386 392
             function_check restart_site
387 393
             restart_site
388 394
 
389
-            systemctl start koal
395
+            systemctl start koel
390 396
         else
391 397
             echo $"koel domain specified but not found in ${temp_backup_dir}"
392 398
         fi
@@ -397,7 +403,7 @@ function restore_remote_koel {
397 403
     if grep -q "koel domain" $COMPLETION_FILE; then
398 404
         echo $"Restoring koel"
399 405
 
400
-        systemctl stop koal
406
+        systemctl stop koel
401 407
 
402 408
         KOEL_DOMAIN_NAME=$(get_completion_param "koel domain")
403 409
 
@@ -410,7 +416,12 @@ function restore_remote_koel {
410 416
             rm -rf /root/tempkoel
411 417
         fi
412 418
 
413
-        systemctl start koal
419
+        MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
420
+        cd /var/www/$KOEL_DOMAIN_NAME/htdocs
421
+        sed -i "s|DB_PASSWORD=.*|DB_PASSWORD=$MARIADB_PASSWORD|g" .env
422
+        MARIADB_PASSWORD=
423
+
424
+        systemctl start koel
414 425
 
415 426
         echo $"Restore of koel complete"
416 427
     fi