@@ -57,18 +57,9 @@ show_usage() {
57
57
printf " \n"
58
58
printf " Options:\n"
59
59
printf " --verbose Show detailed output\n"
60
- printf " -y, --yes Automatic yes to prompts (for uninstall) \n"
60
+ printf " -y, --yes Automatic yes to prompts\n"
61
61
printf " --help Show this help message\n"
62
62
printf " \n"
63
- printf " Examples:\n"
64
- printf " $0 install Install AliasVault using remote images\n"
65
- printf " $0 install start Install AliasVault using remote images and start containers\n"
66
- printf " $0 install stop Stop containers using remote images\n"
67
- printf " $0 install restart Restart containers using remote images\n"
68
- printf " $0 build Build from source\n"
69
- printf " $0 build start Start using local images\n"
70
- printf " $0 build stop Stop containers using local build configuration\n"
71
- printf " $0 build restart Restart containers using local build configuration\n"
72
63
73
64
}
74
65
@@ -210,21 +201,7 @@ main() {
210
201
print_logo
211
202
case $COMMAND in
212
203
" build" )
213
- if [ -z " $COMMAND_ARG " ]; then
214
- handle_build
215
- else
216
- case $COMMAND_ARG in
217
- " start" )
218
- handle_start " build"
219
- ;;
220
- " stop" )
221
- handle_stop " build"
222
- ;;
223
- " restart" )
224
- handle_restart " build"
225
- ;;
226
- esac
227
- fi
204
+ handle_build
228
205
;;
229
206
" install" )
230
207
handle_install " $COMMAND_ARG "
@@ -235,6 +212,12 @@ main() {
235
212
" reset-password" )
236
213
generate_admin_password
237
214
if [ $? -eq 0 ]; then
215
+ printf " ${CYAN} > Restarting admin container...${NC} \n"
216
+ if [ " $VERBOSE " = true ]; then
217
+ $( get_docker_compose_command) up -d --force-recreate admin
218
+ else
219
+ $( get_docker_compose_command) up -d --force-recreate admin > /dev/null 2>&1
220
+ fi
238
221
print_password_reset_message
239
222
fi
240
223
;;
@@ -596,13 +579,14 @@ print_success_message() {
596
579
597
580
# Function to recreate (restart) Docker containers
598
581
recreate_docker_containers () {
599
- printf " ${CYAN} > Recreating Docker containers...${NC} \n"
582
+ printf " ${CYAN} > (Re)creating Docker containers...${NC} \n"
583
+
600
584
if [ " $VERBOSE " = true ]; then
601
- docker compose up -d --force-recreate
585
+ $( get_docker_compose_command ) up -d --force-recreate
602
586
else
603
- docker compose up -d --force-recreate > /dev/null 2>&1
587
+ $( get_docker_compose_command ) up -d --force-recreate > /dev/null 2>&1
604
588
fi
605
- printf " ${GREEN} > Docker containers recreated .${NC} \n"
589
+ printf " ${GREEN} > Docker containers (re)created successfully .${NC} \n"
606
590
}
607
591
608
592
# Function to print password reset success message
@@ -612,11 +596,6 @@ print_password_reset_message() {
612
596
printf " \n"
613
597
printf " ${GREEN} The admin password has been successfully reset, see the output above.${NC} \n"
614
598
printf " \n"
615
- printf " ${YELLOW} Important: You must restart the admin container for the new password to take effect:${NC} \n"
616
- printf " docker compose restart admin\n"
617
- printf " \n"
618
- printf " After restarting, you can login to the admin panel using the new password.\n"
619
- printf " \n"
620
599
printf " ${MAGENTA} =========================================================${NC} \n"
621
600
printf " \n"
622
601
}
@@ -626,7 +605,7 @@ get_docker_compose_command() {
626
605
local base_command=" docker compose -f docker-compose.yml"
627
606
628
607
# Check if using build configuration
629
- if [ " $1 " = " build " ] ; then
608
+ if grep -q " ^DEPLOYMENT_MODE=build " " $ENV_FILE " 2> /dev/null ; then
630
609
base_command=" $base_command -f docker-compose.build.yml"
631
610
fi
632
611
@@ -749,6 +728,8 @@ handle_install() {
749
728
# Function to handle build
750
729
handle_build () {
751
730
printf " ${YELLOW} +++ Building AliasVault from source +++${NC} \n"
731
+ # Set deployment mode to build to ensure container lifecycle uses build configuration
732
+ set_deployment_mode " build"
752
733
printf " \n"
753
734
754
735
# Check for required build files
@@ -811,17 +792,9 @@ handle_build() {
811
792
printf " \n${GREEN} > Docker Compose stack built successfully.${NC} \n"
812
793
813
794
printf " ${CYAN} > Starting Docker Compose stack...${NC} \n"
814
- if [ " $VERBOSE " = true ]; then
815
- $( get_docker_compose_command " build" ) up -d --force-recreate || {
816
- printf " ${RED} > Failed to start Docker Compose stack${NC} \n"
817
- exit 1
818
- }
819
- else
820
- $( get_docker_compose_command " build" ) up -d --force-recreate > /dev/null 2>&1 || {
821
- printf " ${RED} > Failed to start Docker Compose stack${NC} \n"
822
- exit 1
823
- }
824
- fi
795
+
796
+ recreate_docker_containers
797
+
825
798
printf " ${GREEN} > Docker Compose stack started successfully.${NC} \n"
826
799
827
800
# Only show success message if we made it here without errors
@@ -1227,42 +1200,26 @@ generate_self_signed_cert() {
1227
1200
1228
1201
# New functions to handle container lifecycle:
1229
1202
handle_start () {
1230
- local mode=" $1 "
1231
1203
printf " ${CYAN} > Starting AliasVault containers...${NC} \n"
1232
- if [ " $mode " = " build" ]; then
1233
- $( get_docker_compose_command " build" ) up -d
1234
- else
1235
- $( get_docker_compose_command) up -d
1236
- fi
1204
+ $( get_docker_compose_command) up -d
1237
1205
printf " ${GREEN} > AliasVault containers started successfully.${NC} \n"
1238
1206
}
1239
1207
1240
1208
handle_stop () {
1241
- local mode=" $1 "
1242
1209
printf " ${CYAN} > Stopping AliasVault containers...${NC} \n"
1243
1210
if ! docker compose ps --quiet 2> /dev/null | grep -q . ; then
1244
1211
printf " ${YELLOW} > No containers are currently running.${NC} \n"
1245
1212
exit 0
1246
1213
fi
1247
1214
1248
- if [ " $mode " = " build" ]; then
1249
- $( get_docker_compose_command " build" ) down
1250
- else
1251
- $( get_docker_compose_command) down
1252
- fi
1215
+ $( get_docker_compose_command) down
1253
1216
printf " ${GREEN} > AliasVault containers stopped successfully.${NC} \n"
1254
1217
}
1255
1218
1256
1219
handle_restart () {
1257
- local mode=" $1 "
1258
1220
printf " ${CYAN} > Restarting AliasVault containers...${NC} \n"
1259
- if [ " $mode " = " build" ]; then
1260
- $( get_docker_compose_command " build" ) down
1261
- $( get_docker_compose_command " build" ) up -d
1262
- else
1263
- $( get_docker_compose_command) down
1264
- $( get_docker_compose_command) up -d
1265
- fi
1221
+ $( get_docker_compose_command) down
1222
+ $( get_docker_compose_command) up -d
1266
1223
printf " ${GREEN} > AliasVault containers restarted successfully.${NC} \n"
1267
1224
}
1268
1225
@@ -1457,6 +1414,8 @@ handle_install_version() {
1457
1414
fi
1458
1415
1459
1416
printf " ${YELLOW} +++ Installing AliasVault ${target_version} +++${NC} \n"
1417
+ # Set deployment mode to install to ensure container lifecycle uses install configuration
1418
+ set_deployment_mode " install"
1460
1419
printf " \n"
1461
1420
1462
1421
# Initialize workspace which makes sure all required directories and files exist
@@ -1465,6 +1424,7 @@ handle_install_version() {
1465
1424
# Update docker-compose files with correct version so we pull the correct images
1466
1425
handle_docker_compose " $target_version "
1467
1426
1427
+
1468
1428
# Initialize environment
1469
1429
create_env_file || { printf " ${RED} > Failed to create .env file${NC} \n" ; exit 1; }
1470
1430
populate_hostname || { printf " ${RED} > Failed to set hostname${NC} \n" ; exit 1; }
@@ -1725,4 +1685,14 @@ handle_migrate_db() {
1725
1685
printf " ${GREEN} > Check migration output above for details.${NC} \n"
1726
1686
}
1727
1687
1688
+ # Function to set deployment mode in .env
1689
+ set_deployment_mode () {
1690
+ local mode=$1
1691
+ if [ " $mode " != " build" ] && [ " $mode " != " install" ]; then
1692
+ printf " ${RED} Invalid deployment mode: $mode ${NC} \n"
1693
+ exit 1
1694
+ fi
1695
+ update_env_var " DEPLOYMENT_MODE" " $mode "
1696
+ }
1697
+
1728
1698
main " $@ "
0 commit comments