forked from Nimdy/Dedicated_Valheim_Server_Script
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnjordmenu.sh
More file actions
3439 lines (3205 loc) · 143 KB
/
njordmenu.sh
File metadata and controls
3439 lines (3205 loc) · 143 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
###############################################################################################
###############################################################################################
####
#### From: Zerobandwidth
####
#### Thank you for using the menu script, this started out as just me and blew up quickly.
#### If Frankenstein was a bash script, this is what you would get, so please help me improve it.
#### Feel free to use and change this as you wish just not for profit.
#### If you need anything, please visit our Discord Server: https://discord.gg/ejgQUfc
#### *** GLHF - V/r, Zerobandwidth and Team
####
###############################################################################################
####
#### File name: ldadvmenu.sh
####
###############################################################################################
####
#### Modifier: Lord/Ranger(Dumoss)
#### Forked from: Njord advancemenu.ld (beta) Updated: 29-APR-2021
####
#### I would like to thank "Dr." Zerobandwidth "Frankenstein"
#### and the development team of "Igor's" for putting
#### this wonderfull "monster" script together. :)
####
#### The main focus of this was to add Linux support for
#### Fedora-Cento-RHEL-OEL-yum/dnf based systems.
####
#### To allow control multiple Valheim servers running on a single node
#### based on WORLDNAME and is installed under "${worldpath}/${worldname}"
####
#### TO have some simple firewall security control related to these systems. - (WIP)
####
#### *** - Dumoss
####
###############################################################################################
###############################################################################################
#### Current Options: DE=German, EN=English, FR=French, SP=Spanish"
###############################################################################################
###############################################################################################
# All linux systems should have this
# If not .. <> install os-release
source /etc/os-release
if [ "$1" == "" ]
then
LANGUAGE=EN
else
LANGUAGE=$1
fi
source lang/$LANGUAGE.conf
#############################################################
######################## Santiy Check #####################
#############################################################
echo "$(tput setaf 4)"$DRAW60""
echo "$(tput setaf 0)$(tput setab 7)"$CHECKSUDO"$(tput sgr 0)"
echo "$(tput setaf 0)$(tput setab 7)"$CHECKSUDO1"$(tput sgr 0)"
echo "$(tput setaf 4)"$DRAW60""
# ######################################################
[[ "$EUID" -eq 0 ]] || exec sudo "$0" "$@"
clear
###############################################################
################### Default Variables #########################
###############################################################
### NOTE: Only change this if you know what you are doing ###
###############################################################
###############################################################
### Valheim Server Install location(Default)
valheimInstallPath=/home/steam/valheimserver
### Valheim World Data Path(Default)
worldpath=/home/steam/.config/unity3d/IronGate/Valheim
### Keeps a list of created Valheim Worlds
worldfilelist=/home/steam/worlds.txt
### Backup Directory ( Default )
backupPath=/home/steam/backups
###
### Configs for Advance Users ###
### This option is only for the steamcmd install where it
### is not included in the "steam" client install ... ie RH/OEL-yum
### Set this to delete all files from the /home/steam/steamcmd directory to install steamcmd fresh.
### Defaults are "n" on the below parameters.
### <n : no>
### <y : yes>
freshinstall="n"
### **** Firewall setup ***
### Do you use a firewall?
usefw="n"
### what firewall do you want to use?
#Change the following value to one listed in the fwsystems list below or use 'none'.
fwbeingused="firewalld"
# Do not changed this only add to it.
fwsystems=( arptables ebtables firewalld iptables ip6tables ufw )
###############################################################
debugmsg="n"
# if [ "$debugmsg" == "y" ] ; then echo "something" ; fi
###############################################################
# Set Menu Version for menu display
mversion="3.5-lokis-dance"
ldversion="0.4.051120211500ET.dev"
### -- Use are your own risk --
### dev -- Still working on firewall code.
### -- Currently adding ufw commands.
### -- And then finish the firewall menu (make pro).
### alpha -- Dev team review.
### beta -- Public Testing.
###
### Please note that this is a play ground file for me and
### allows Zerobandwidth do determine what to pull into the main advance(menu).sh file.
###
### I have done a lot ( and still ) testing of this new code
### and it seams to be working as original intended, but
### now for OEL/REL/Fedora and centos tested.
###
### If you are using the above server versions of Linux and the added repos cause issues,
### I have provided the 3 most causes and fixes in the function ***linux_server_update*** text.
###
### I am still in design mode for the firewall stuff.
### Current it works 99% for FireWallD only at this time.
###
### Other Linux flavors and firewall systems to be added.
########################################################################
#############################Set COLOR VARS#############################
########################################################################
NOCOLOR='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
LIGHTRED='\033[1;31m'
LIGHTGREEN='\033[1;32m'
YELLOW='\033[1;33m'
WHITE='\033[1;37m'
clear='\e[0m'
##
# Color Functions
##
ColorRed(){
echo -ne $RED$1$clear
}
ColorGreen(){
echo -ne $GREEN$1$clear
}
ColorOrange(){
echo -ne $ORANGE$1$clear
}
ColorBlue(){
echo -ne $BLUE$1$clear
}
ColorPurple(){
echo -ne $PURPLE$1$clear
}
ColorCyan(){
echo -ne $CYAN$1$clear
}
ColorLightRed(){
echo -ne $LIGHTRED$1$clear
}
ColorLightGreen(){
echo -ne $LIGHTGREEN$1$clear
}
ColorYellow(){
echo -ne $LIGHTYELLOW$1$clear
}
ColorWhite(){
echo -ne $WHITE$1$clear
}
########################################################################
#####################Check for Menu Updates#############################
########################################################################
MENUSCRIPT="$(readlink -f "$0")"
SCRIPTFILE="$(basename "$MENUSCRIPT")"
SCRIPTPATH="$(dirname "$SCRIPT")"
SCRIPTNAME="$0"
ARGS=( "$@" )
BRANCH=$(git rev-parse --abbrev-ref HEAD)
UPSTREAM=$(git rev-parse --abbrev-ref --symbolic-full-name @{upstream})
function script_check_update() {
#Look for updates from repo tag
echo "1"
git fetch
[ -n "$(git diff --name-only "$UPSTREAM" "$SCRIPTFILE")" ] && {
echo "$GIT_ECHO_CHECK"
sleep 1
git pull --force
git stash
git checkout "$BRANCH"
git pull --force
echo "$GIT_ECHO_UPDATING"
sleep 1
chmod +x *menu.sh
sleep 1
exec "$SCRIPTNAME" "${ARGS[@]}"
# Now exit this old instance
exit 1
}
echo "$GIT_ECHO_NO_UPDATES"
}
########################################################################
##############MAIN VALHEIM SERVER ADMIN FUNCTIONS START#################
########################################################################
########################################################################
#####################Install Valheim Server START#######################
########################################################################
function valheim_server_steam_account_creation() {
# create steam account
# later add top variable for steam user because maybe somebody already has a steam account for something else?
echo "$START_INSTALL_1_PARA"
while true;
do
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 2; echo "$STEAM_NON_ROOT_STEAM_PASSWORD" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 1; echo "$STEAM_PASS_MUST_BE" ; tput setaf 9;
tput setaf 1; echo "$STEAM_PASS_MUST_BE_1" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 2; echo "$STEAM_GOOD_EXAMPLE" ; tput setaf 9;
tput setaf 1; echo "$STEAM_BAD_EXAMPLE" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
echo ""
read -p "$STEAM_PLEASE_ENTER_STEAM_PASSWORD" userpassword
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
[[ ${#userpassword} -ge 6 && "$userpassword" == *[[:lower:]]* && "$userpassword" == *[[:upper:]]* && "$userpassword" =~ ^[[:alnum:]]+$ ]] && break
tput setaf 2; echo "$STEAM_PASS_NOT_ACCEPTED" ; tput setaf 9;
tput setaf 2; echo "$STEAM_PASS_NOT_ACCEPTED_1" ; tput setaf 9;
done
echo ""
# Set the env bash profile information for steam user
tput setaf 1; echo "$INSTALL_BUILD_NON_ROOT_STEAM_ACCOUNT" ; tput setaf 9;
sleep 1
if command -v apt-get >/dev/null; then
useradd --create-home --shell /bin/bash --password $userpassword steam
cp /etc/skel/.bashrc /home/steam/.bashrc
cp /etc/skel/.profile /home/steam/.profile
elif command -v yum >/dev/null; then
useradd -mU -s /bin/bash -p $userpassword steam
# All file from /etc/skel/ are auto copied on RH.
else
echo ""
fi
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
}
function valheim_server_public_server_display_name() {
echo ""
# Take user input for Valheim Server Public Display
echo ""
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 2; echo "$PUBLIC_SERVER_DISPLAY_NAME" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 1; echo "$PUBLIC_SERVER_DISPLAY_NAME_1" ; tput setaf 9;
tput setaf 1; echo "$PUBLIC_SERVER_DISPLAY_NAME_2" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 2; echo "$PUBLIC_SERVER_DISPLAY_GOOD_EXAMPLE" ; tput setaf 9;
tput setaf 2; echo "$PUBLIC_SERVER_DISPLAY_GOOD_EXAMPLE_1" ; tput setaf 9;
tput setaf 1; echo "$PUBLIC_SERVER_DISPLAY_BAD_EXAMPLE" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
echo ""
read -p "$PUBLIC_SERVER_ENTER_NAME" displayname
tput setaf 2; echo "------------------------------------------------------------" ; tput setaf 9;
echo ""
}
function valheim_server_local_world_name() {
# Set world name function that will be used for .db and .fwl files
echo ""
while true;
do
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 2; echo "$WORLD_SET_WORLD_NAME_HEADER" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 1; echo "$WORLD_SET_CHAR_RULES" ; tput setaf 9;
tput setaf 1; echo "$WORLD_SET_NO_SPECIAL_CHAR_RULES" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 2; echo "$WORLD_GOOD_EXAMPLE" ; tput setaf 9;
tput setaf 1; echo "$WORLD_BAD_EXAMPLE" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
echo ""
read -p "$WORLD_SET_WORLD_NAME_VAR" worldname
tput setaf 2; echo "------------------------------------------------------------" ; tput setaf 9;
[[ ${#worldname} -ge 4 && "$worldname" =~ ^[[:alnum:]]+$ ]] && break
tput setaf 2; echo "$WORLD_SET_ERROR" ; tput setaf 9;
tput setaf 2; echo "$WORLD_SET_ERROR_1" ; tput setaf 9;
done
clear
echo ""
}
function valheim_server_public_valheim_port() {
# Take user input for Valheim Server port.
# Will be adding some port checks during my firewall steps.
echo ""
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 2; echo "$FUNCTION_VALHEIM_SERVER_INSTALL_LD_SETPORTNEW_HEADER" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 1; echo "$FUNCTION_VALHEIM_SERVER_INSTALL_LD_SETPORTNEW_INFO1" ; tput setaf 9;
tput setaf 1; echo "$FUNCTION_VALHEIM_SERVER_INSTALL_LD_SETPORTNEW_INFO2" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 2; echo "$FUNCTION_VALHEIM_SERVER_INSTALL_LD_SETPORTNEW_INFO3" ; tput setaf 9;
tput setaf 2; echo "$FUNCTION_VALHEIM_SERVER_INSTALL_LD_SETPORTNEW_INFO4" ; tput setaf 9;
tput setaf 1; echo "$FUNCTION_VALHEIM_SERVER_INSTALL_LD_SETPORTNEW_INFO5" ; tput setaf 9;
#### Get currently used ports and display them here along side worldnames
#### IE: World Names and Ports currently in use:
#### World Name: Example World Ports Used: 2456-2458
#### World Name: Example 2 Ports Used: 2359-2461
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
echo ""
while true; do
read -p "$FUNCTION_VALHEIM_SERVER_INSTALL_LD_SETPORTNEW_ENTER" portnumber
### write check if new port is = used ports => try again, error
#usedport="$(perl -n -e '/\-port "?([^"]+)"? \-nographics/ && print "$1\n"' start_valheim_${worldname}.sh)"
[[ ${#portnumber} -ge 4 && ${#portnumber} -le 6 ]] && [[ $portnumber -gt 1024 && $portnumber -le 65530 ]] && [[ "$portnumber" =~ ^[[:alnum:]]+$ ]] & break
done
tput setaf 2; echo "------------------------------------------------------------" ; tput setaf 9;
clear
echo ""
}
function valheim_server_public_listing() {
# set public listing
# 1 = Display Server
# 0 = LAN or do not Display Server public
echo ""
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 2; echo "$PUBLIC_ENABLED_DISABLE_HEADER" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 1; echo "$PUBLIC_ENABLED_DISABLE_INFO" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 2; echo "$PUBLIC_ENABLED_DISABLE_EXAMPLE_SHOW" ; tput setaf 9;
tput setaf 1; echo "$PUBLIC_ENABLED_DISABLE_EXAMPLE_LAN_NO_SHOW" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
echo ""
read -p "$PUBLIC_ENABLED_DISABLE_INPUT" publicList
tput setaf 2; echo "------------------------------------------------------------" ; tput setaf 9;
echo ""
echo "$CREDS_DISPLAY_CREDS_PRINT_OUT_HEADER"
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 2; echo "$CREDS_DISPLAY_CREDS_PRINT_OUT_STEAM_PASSWORD $userpassword " ; tput setaf 9;
tput setaf 2; echo "$CREDS_DISPLAY_CREDS_PRINT_OUT_SERVER_NAME $displayname " ; tput setaf 9;
tput setaf 2; echo "$CREDS_DISPLAY_CREDS_PRINT_OUT_WORLD_NAME $worldname " ; tput setaf 9;
tput setaf 2; echo "Port number being used: $portnumber " ; tput setaf 9;
tput setaf 2; echo "$CREDS_DISPLAY_CREDS_PRINT_OUT_ACCESS_PASS $password " ; tput setaf 9;
tput setaf 2; echo "$CREDS_DISPLAY_CREDS_PRINT_OUT_SHOW_PUBLIC $publicList " ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
echo ""
}
function valheim_server_public_access_password() {
# added security for password complex
echo ""
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 2; echo "$SERVER_ACCESS_PASS_HEADER" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 1; echo "$SERVER_ACCESS_INFO" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 2; echo "$SERVER_ACCESS_PUBLIC_NAME_INFO $displayname " ; tput setaf 9;
tput setaf 2; echo "$SERVER_ACCESS_WORLD_NAME_INFO $worldname " ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
while true;
do
tput setaf 1; echo "$SERVER_ACCESS_WARN_INFO" ; tput setaf 9;
tput setaf 1; echo "$SERVER_ACCESS_WARN_INFO_1" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 2; echo "$SERVER_ACCESS_GOOD_EXAMPLE" ; tput setaf 9;
tput setaf 1; echo "$SERVER_ACCESS_BAD_EXAMPLE" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
read -p "$SERVER_ACCESS_ENTER_PASSWORD" password
tput setaf 2; echo "------------------------------------------------------------" ; tput setaf 9;
[[ ${#password} -ge 5 && "$password" == *[[:lower:]]* && "$password" == *[[:upper:]]* && "$password" =~ ^[[:alnum:]]+$ ]] && break
tput setaf 2; echo "$SERVER_ACCESS_PASSWORD_ERROR" ; tput setaf 9;
tput setaf 2; echo "$SERVER_ACCESS_PASSWORD_ERROR_1" ; tput setaf 9;
done
}
function valheim_server_set_crossplay() {
echo ""
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 2; echo "Set up Crossplay" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 1; echo "Crossplay allows you to play with friends on other platforms" ; tput setaf 9;
tput setaf 2; echo "Crossplay 1 = Enabled" ; tput setaf 9;
tput setaf 2; echo "Crossplay 0 = Disabled" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
tput setaf 2; echo "Do you wish to enable Crossplay?" ; tput setaf 9;
tput setaf 2; echo "$DRAW60" ; tput setaf 9;
echo ""
read -p "Enter 1 for Yes or 0 for No: " crossplay
tput setaf 2; echo "------------------------------------------------------------" ; tput setaf 9;
echo ""
}
function build_configuration_env_files_set_permissions(){
#Populate Admin/config files
echo "$DRAW60" >> /home/steam/serverSetup.txt
echo $CREDS_DISPLAY_CREDS_PRINT_OUT_STEAM_PASSWORD $userpassword >> /home/steam/serverSetup.txt
echo $CREDS_DISPLAY_CREDS_PRINT_OUT_SERVER_NAME $displayname >> /home/steam/serverSetup.txt
echo $CREDS_DISPLAY_CREDS_PRINT_OUT_WORLD_NAME $worldname >> /home/steam/serverSetup.txt
echo $CREDS_DISPLAY_CREDS_PRINT_OUT_PORT_USED $portnumber >> /home/steam/serverSetup.txt
echo $CREDS_DISPLAY_CREDS_PRINT_OUT_ACCESS_PASS $password >> /home/steam/serverSetup.txt
echo $CREDS_DISPLAY_CREDS_PRINT_OUT_SHOW_PUBLIC $publicList >> /home/steam/serverSetup.txt
echo "CrossPlay Option 1 = Enabled - 0 = Disabled" $crossplay>> /home/steam/serverSetup.txt
echo "$DRAW60" >> /home/steam/serverSetup.txt
sleep 1
echo $worldname >> /home/steam/worlds.txt
sleep 1
chown steam:steam /home/steam/*.txt
clear
}
function valheim_server_install() {
clear
echo ""
if [ "$newinstall" == "y" ]; then
tput setaf 2; echo "Thank you for using the Njord Menu system." ; tput setaf 9;
tput setaf 2; echo "This appears to be the first time the menu has" ; tput setaf 9;
tput setaf 2; echo "been run on this system." ; tput setaf 9;
tput setaf 2; echo "Installing the first Valheim server started." ; tput setaf 9;
linux_server_update
valheim_server_steam_account_creation
valheim_server_public_server_display_name
valheim_server_local_world_name
portnumber=2456
valheim_server_public_listing
valheim_server_public_access_password
valheim_server_set_crossplay
build_configuration_env_files_set_permissions
Install_steamcmd_client
else
#for adding another valheim install on the same server skipping steam user creation
valheim_server_public_server_display_name
valheim_server_local_world_name
valheim_server_public_valheim_port
valheim_server_public_listing
valheim_server_public_access_password
valheim_server_set_crossplay
build_configuration_env_files_set_permissions
fi
nocheck_valheim_update_install
tput setaf 1; echo "$INSTALL_BUILD_SET_STEAM_PERM" ; tput setaf 9;
chown steam:steam -Rf /home/steam/*
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 1
#### Need to add code to veriy firewall system and if enabled.
#### Below is the line needed for Valheim
#### These should also be added to as port forwards on your network router.
####
#
if [ "${usefw}" == "y" ] ; then
if [ "${fwbeingused}" == "ufw" ] ; then
if command -v ufw >/dev/null; then
sudo ufw allow ${portnumber}:${portnumber+2}/upd
# The above command needs to be validated.
echo "Adding ports to the UFW system."
fi
elif [ "${fwbeingused}" == "iptables" ] ; then
if command -v iptables >/dev/null; then
# sudo iptables –A INPUT –p upd ––dport ${portnumber},${portnumber}+1,${portnumber}+2) –j ACCEPT
#if [ "$ID" == "fedora" ] || [ "$ID "= "centos" ] || [ "$ID" == "ol" ] || [ "$ID" = "rhel" ] ) ; then
# sudo /sbin/service iptables save
#else
# sudo /sbin/iptables–save
#fi
echo ""
fi
elif [ "${fwbeingused}" == "firewalld" ] ; then
if command -v firewalld >/dev/null; then
if [ "$is_firewall_enabled" == "y" ] ; then
if [ "$get_firewall_status" == "y" ] ; then
sftc="val"
add_Valheim_server_public_ports
fi
fi
fi
else
echo ""
fi
else
if [ "${is_firewall_enabled}" == "y" ] ; then
disable_all_firewalls
fi
fi
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 1
#build config for start_valheim.sh
tput setaf 1; echo "$INSTALL_BUILD_DELETE_OLD_CONFIGS" ; tput setaf 9;
tput setaf 1; echo "$INSTALL_BUILD_DELETE_OLD_CONFIGS_1" ; tput setaf 9;
[ -e ${valheimInstallPath}/${worldname}/start_valheim_${worldname}.sh ] && rm ${valheimInstallPath}/${worldname}/start_valheim_${worldname}.sh
sleep 1
cat >> ${valheimInstallPath}/${worldname}/start_valheim_${worldname}.sh <<EOF
#!/bin/bash
export templdpath=\$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=./linux64:\$LD_LIBRARY_PATH
export SteamAppId=892970
# Tip: Make a local copy of this script to avoid it being overwritten by steam.
# NOTE: Minimum password length is 5 characters & Password cant be in the server name.
# NOTE: You need to make sure the ports 2456-2458 is being forwarded to your server through your local router & firewall.
./valheim_server.x86_64 -name "${displayname}" -port "${portnumber}" -nographics -batchmode -world "${worldname}" -password "${password}" -public "${publicList}" -savedir "${worldpath}/${worldname}" -logfile "${worldpath}/${worldname}/valheim_server.log" -crossplay "${crossplay}"
export LD_LIBRARY_PATH=\$templdpath
EOF
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 1
#delete old check log script, not required any longer.
tput setaf 1; echo "$INSTALL_BUILD_DELETE_OLD_SCRIPT" ; tput setaf 9;
[ -e /home/steam/check_log.sh ] && rm /home/steam/check_log.sh
#set execute permissions
tput setaf 1; echo "$INSTALL_BUILD_SET_PERM_ON_START_VALHEIM" ; tput setaf 9;
chmod +x ${valheimInstallPath}/${worldname}/start_valheim_${worldname}.sh
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 1
#build systemctl configurations for execution of processes for Valheim Server
tput setaf 1; echo "$INSTALL_BUILD_DEL_OLD_SERVICE_CONFIG" ; tput setaf 9;
tput setaf 1; echo "$INSTALL_BUILD_DEL_OLD_SERVICE_CONFIG_1" ; tput setaf 9;
# remove old Valheim Server Service
[ -e /etc/systemd/system/valheimserver_${worldname}.service ] && rm /etc/systemd/system/valheimserver_${worldname}.service
# remove past Valheim Server Service
[ -e /lib/systemd/system/valheimserver_${worldname}.service ] && rm /lib/systemd/system/valheimserver_${worldname}.service
sleep 1
# Add new Valheim Server Service
# Thanks @QuadeHale
cat >> /lib/systemd/system/valheimserver_${worldname}.service <<EOF
[Unit]
Description=Valheim Server
Wants=network-online.target
After=syslog.target network.target nss-lookup.target network-online.target
[Service]
Type=simple
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
User=steam
Group=steam
ExecStartPre=$steamexe +login anonymous +force_install_dir ${valheimInstallPath}/${worldname} +app_update 896660 validate +exit
ExecStart=${valheimInstallPath}/${worldname}/start_valheim_${worldname}.sh
ExecReload=/bin/kill -s HUP \$MAINPID
KillSignal=SIGINT
WorkingDirectory=${valheimInstallPath}/${worldname}
LimitNOFILE=100000
[Install]
WantedBy=multi-user.target
EOF
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 1
#chown steam user permissions to all of user steam dir location
tput setaf 1; echo "$INSTALL_BUILD_SET_STEAM_PERMS" ; tput setaf 9;
chown steam:steam -Rf /home/steam/*
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 1
# Reload daemons
tput setaf 1; echo "$INSTALL_BUILD_RELOAD_DAEMONS" ; tput setaf 9;
systemctl daemon-reload
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 1
# Start server
tput setaf 1; echo "$INSTALL_BUILD_START_VALHEIM_SERVICE" ; tput setaf 9;
systemctl start valheimserver_${worldname}.service
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 1
# Enable server on restarts
tput setaf 1; echo "$INSTALL_BUILD_ENABLE_VALHEIM_SERVICE" ; tput setaf 9;
systemctl enable valheimserver_${worldname}.service
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 2
clear
tput setaf 2; echo "$INSTALL_BUILD_FINISH_THANK_YOU" ; tput setaf 9;
echo ""
echo ""
}
########################################################################
#####################Install Valheim Server END#########################
########################################################################
########################################################################
############ Linux server update - requirement #############
########################################################################
# LordDumoss (LD): Add yum support. Might be a better way. But it works.
# LD: Changed where the steamcmd required libs are installed.
########################################################################
# SUDO?
#########
function linux_server_update() {
#check for updates and upgrade the system auto yes
# ID=debian=apt
# ID=ubuntu=apt
# ID=FreeBSD=pkg
echo "$ID"
echo "$VERSION"
echo "${VERSION:0:1}"
tput setaf 1; echo "$CHECK_FOR_UPDATES" ; tput setaf 9;
if command -v apt-get >/dev/null; then
sudo apt update && apt upgrade -y
elif command -v pkg >/dev/null; then
echo "Insert command here."
#elif command -v dnf >/dev/null; then
elif command -v yum >/dev/null; then
if [[ "$ID" == "fedora" ]] || [[ ( "$ID" == "centos" || "$ID" == "ol" || "$ID" == "rhel" ) && "${VERSION:0:1}" == "8" ]] ; then
sudo dnf clean all && dnf update -y && dnf upgrade -y
elif [[ ( "$ID" == "centos" || "$ID" == "ol" || "$ID" == "rhel" ) && "${VERSION:0:1}" == "7" ]] ; then
sudo yum clean all && yum update -y && yum upgrade -y
echo "yum'ed"
else
echo "oops1"
fi
else
echo "oops2"
fi
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 1
# Nimdy: check for updates and upgrade the system auto yes
# WTF is curl not installed by default... come on man!
tput setaf 1; echo "$INSTALL_ADDITIONAL_FILES" ; tput setaf 9;
if command -v apt-get >/dev/null; then
sudo apt install lib32gcc1 libsdl2-2.0-0 libsdl2-2.0-0:i386 git mlocate net-tools unzip curl isof -y
#elif command -v dnf >/dev/null; then
# Seams RH went to dnf as well in RHEL8
# Might use ID_LIKE="fedora" and VERSION_ID="7.9" instead? But this works.
#
elif command -v yum >/dev/null; then
if [[ "$ID" == "fedora" ]] || [[ ( "$ID" == "centos" || "$ID" == "ol" || "$ID" == "rhel" ) && "${VERSION:0:1}" == "8" ]] ; then
sudo dnf install glibc.i686 libstdc++.i686 git mlocate net-tools unzip curl isof -y
elif [[ ( "$ID" == "centos" || "$ID" == "ol" || "$ID" == "rhel" ) && "${VERSION:0:1}" == "7" ]] ; then
sudo yum install glibc.i686 libstdc++.i686 git mlocate net-tools unzip curl isof -y
echo "yum'ed"
else
echo "oops3"
fi
else
echo "oops4"
fi
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 1
#install software-properties-common for add-apt-repository command below
tput setaf 1; echo "$INSTALL_SPCP" ; tput setaf 9;
if command -v apt-get >/dev/null; then
sudo apt install software-properties-common
#elif command -v yum >/dev/null; then
else
echo "$FUNCTION_LINUX_SERVER_UPDATE_YUM_REQUIRED_NO"
fi
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 1
#add the MULTIVERSE repo(s) per Linux Flavor.
tput setaf 1; echo "$ADD_MULTIVERSE" ; tput setaf 9;
if command -v apt-get >/dev/null; then
sudo add-apt-repository -y multiverse
elif command -v yum >/dev/null; then
#if command -v dnf >/dev/null; then
# Need to add the following repos.
#### Adding these repos allowed steam/vulkan/and the other dependances to install on OEL/RH7/Fedora2+
#### I even tested starting the steam gui interface. It started just fine.
#### https://negativo17.org/steam/
#### Remeber the repos keys ... https://rpmfusion.org/keys
if [[ "$ID" == "fedora" ]] || [[ ( "$ID" == "centos" || "$ID" == "ol" || "$ID" == "rhel" ) && "${VERSION:0:1}" == "8" ]] ; then
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf config-manager --add-repo=http://mirror.centos.org/centos/8/os/x86_64/
sudo dnf install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
sudo dnf config-manager --add-repo=https://negativo17.org/repos/fedora-negativo17.repo
elif [[ ( "$ID" == "centos" || "$ID" == "ol" || "$ID" == "rhel" ) && "${VERSION:0:1}" == "7" ]] ; then
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum-config-manager --add-repo=http://mirror.centos.org/centos/7/os/x86_64/
sudo yum localinstall --nogpgcheck https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm
sudo yum localinstall --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-nonfree-release-7.noarch.rpm
sudo yum-config-manager --add-repo=https://negativo17.org/repos/epel-negativo17.repo
else
echo "oops5"
fi
else
echo "oops6"
fi
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 1
#add i386 architecture
tput setaf 1; echo "$ADD_I386" ; tput setaf 9;
if command -v apt-get >/dev/null; then
sudo dpkg --add-architecture i386
#elif command -v yum >/dev/null; then
else
echo "$FUNCTION_LINUX_SERVER_UPDATE_RHL_REQUIRED_NO"
fi
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 1
#update system again
tput setaf 1; echo "$CHECK_FOR_UPDATES_AGAIN" ; tput setaf 9;
if command -v apt-get >/dev/null; then
sudo apt update && apt install -y libpulse-dev libatomic1 libc6
elif command -v yum >/dev/null; then
#elif command -v dnf >/dev/null; then
if [[ "$ID" == "fedora" ]] || [[ ( "$ID" == "centos" || "$ID" == "ol" || "$ID" == "rhel" ) && "${VERSION:0:1}" == "8" ]] ; then
sudo dnf update
elif [[ ( "$ID" == "centos" || "$ID" == "ol" || "$ID" == "rhel" ) && "${VERSION:0:1}" == "7" ]] ; then
sudo yum update
else
echo "oops6"
fi
fi
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 1
}
########################################################################
################# LD: Install the steamcmd #############
########################################################################
function Install_steamcmd_client() {
#install steamcmd
#### This depends on the Linux flavor and/or whether you need the graphic client or the command line only.
tput setaf 1; echo "$INSTALL_STEAMCMD_LIBSD12" ; tput setaf 9;
# ID=debian
# ID=ubuntu
# ID=FreeBSD=pkg
if command -v apt-get >/dev/null; then
echo steam steam/license note '' | debconf-set-selections
echo steam steam/question select 'I AGREE' | debconf-set-selections
#' fixes coding breaking for viewing in editors only.... dont ask me why... thanks auto accept agreement syntax above
sudo apt install steamcmd libsdl2-2.0-0 libsdl2-2.0-0:i386 -y
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
elif command -v yum >/dev/null; then
#if command -v dnf >/dev/null; then
if [[ "$ID" == "fedora" ]] || [[ ( "$ID" == "centos" || "$ID" == "ol" || "$ID" == "rhel" ) && "${VERSION:0:1}" == "8" ]] ; then
sudo dnf -y install steam kernel-modules-extra
elif [[ ( "$ID" == "centos" || "$ID" == "ol" || "$ID" == "rhel" ) && "${VERSION:0:1}" == "7" ]] ; then
sudo yum install steam -y
else
echo "oops7"
fi
########################################################################
######################### repo help #################################
########################################################################
###
### You might have the following issues adding the above repos to RH/OeL
###
### Why not just remove if exists.
### If problems with the added repos like
### --> Finished Dependency Resolution
### Error: Package: ntp-4.2.6p5-22.el7.centos.2.x86_64 (@updates)
### Requires: ntpdate = 4.2.6p5-22.el7.centos.2
###
### It is because of duplicate entries in the yum local db.
### To fix:
###
### yum install yum-tools
### rpm -Va > rpmrequest.txt
### This reports them
### sudo package-cleanup --dupes
### This fix them
### sudo package-cleanup --cleandupes
###
########################################################################
###
### Transaction check error:
### file /usr/share/man/man1/pango-view.1.gz from install of pango-1.42.4-4.el7_7.i686 conflicts with file from package pango-1.42.4-4.el7_7.x86_64
### file /usr/share/man/man1/gtk-query-immodules-2.0.1.gz from install of gtk2-2.24.31-1.el7.i686 conflicts with file from package gtk2-2.24.31-1.el7.x86_64
### ...
###
### These error happen when dependent rpms are being installed for steam (or just update/upgrade)
### and where the reported rpm is already installed from another repo.
###
### The fix this is easy.
###
### <ctrl-c> out of menu
###
### Reinstall all of the listed in output like this:
###
### yum reinstall pango.x86_64 gtk2.x86_64
###
### This installs the rpm listed in the output from the newly added repos and fixes the error.
###
### Rerun the menu script.
###
########################################################################
###
### The last thing you might need to do is downgrade an rmp/lib version needed for steam
### , which a higher unsupport version is installed
### yum downgrade <name>
### or just *** yum remove <name> ***
### and let the *** yum install steam ***
### Install correct version.
###
########################################################################
# Because there is 100% no yum steamcmd still need to
steamzipfile="/home/steam/steamcmd/steamcmd_linux.tar.gz"
cd /home/steam
mkdir steamcmd
cd /home/steam/steamcmd
if [ -fe $steamzipfile ] ; then
rm $steamzipfile
fi
if [ "$freshinstall" = "y" ] ; then
rm -rfv /home/steam/steamcmd/*
fi
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar xf steamcmd_linux.tar.gz
fi
#### Need to add code to veriy firewall system and if enabled.
#### Below is the line needed for steamcmd
#### These should also be added to as port forwards on your network router.
if [ "${usefw}" == "y" ] ; then
if [ "${fwbeingused}" == "ufw" ] ; then
if command -v ufw >/dev/null; then
# ufw allow udp from any to any port $minportnumber-$maxportnumber
# The above command needs to be validated.
sudo ufw allow 1200/udp
sudo ufw allow 27020/udp
sudo ufw allow 27000-27015/udp
sudo ufw allow 27015-27016/both
sudo ufw allow 27030-27039/both
echo "WIP Need to add."
echo ""
fi
elif [ "${fwbeingused}" == "iptables" ] ; then
#if command -v iptables >/dev/null; then ; fi
#if command -v ip6tables >/dev/null; then ; fi
#if command -v ebtables >/dev/null; then ; fi
echo "WIP Need to add."
elif [ "${fwbeingused}" == "firewalld" ] ; then
if command -v firewalld >/dev/null; then
if [ "$is_firewall_enabled" == "y" ] ; then
if [ "$get_firewall_status" == "y" ] ; then
sftc="ste"
add_Valheim_server_public_ports
fi
fi
fi
else
echo ""
fi
else
if [ "${is_firewall_enabled}" == "y" ] ; then
disable_all_firewalls
fi
fi
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 1
#build symbolic link for steamcmd
#Guess it is time to install UBUNTU to see these diffs.
tput setaf 1; echo "$INSTALL_BUILD_SYM_LINK_STEAMCMD" ; tput setaf 9;
if command -v apt-get >/dev/null; then
ln -s /usr/games/steamcmd /home/steam/steamcmd
elif command -v yum >/dev/null; then
ln -s /usr/games/steamcmd /home/steam/steamcmd/linux32/steamcmd
else
echo "oops8"
fi
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
sleep 1
}
########################################################################
##########Backup and Restore World DB and FWL Files START###############
########################################################################
#Backup World DB and FWL Files
function backup_world_data() {
echo ""
echo ""
#read user input confirmation
tput setaf 1; echo "$BACKUP_WORLD_DATA_HEADER" ; tput setaf 9;
tput setaf 1; echo "$BACKUP_WORLD_INFO_CONFIRM" ; tput setaf 9;
read -p "$BACKUP_WORLD_INPUT_CONFIRM_Y_N" confirmBackup
#if y, then continue, else cancel
if [ "$confirmBackup" == "y" ]; then
## Get the current date as variable.
TODAY="$(date +%Y-%m-%d-%T)"
tput setaf 5; echo "$BACKUP_WORLD_CHECK_DIRECTORY" ; tput setaf 9;
tput setaf 5; echo "$BACKUP_WORLD_CHECK_DIRECTORY_1" ; tput setaf 9;
dldir=$backupPath/$worldname
[ ! -d "$dldir" ] && mkdir -p "$dldir"
sleep 1
## Clean up files older than 2 weeks. Create a new backup.
tput setaf 1; echo "$BACKUP_WORLD_CONDUCT_CLEANING" ; tput setaf 9;
find $backupPath/$worldname/* -mtime +14 -type f -delete
tput setaf 2; echo "$BACKUP_WORLD_CONDUCT_CLEANING_LOKI" ; tput setaf 9;
sleep 1
## Tar Section. Create a backup file, with the current date in its name.
## Add -h to convert the symbolic links into a regular files.
## Backup some system files, also the entire `/home` directory, etc.
##--exclude some directories, for example the the browser's cache, `.bash_history`, etc.
#stop valheim server
tput setaf 1; echo "$BACKUP_WORLD_STOPPING_SERVICES" ; tput setaf 9;
systemctl stop valheimserver_${worldname}.service
tput setaf 1; echo "$BACKUP_WORLD_STOP_INFO" ; tput setaf 9;
tput setaf 2; echo "$BACKUP_WORLD_STOP_INFO_1" ; tput setaf 9;
tput setaf 2; echo "$BACKUP_WORLD_STOP_WAIT_10_SEC" ; tput setaf 9;
#give it a few
sleep 10
tput setaf 1; echo "$BACKUP_WORLD_MAKING_TAR" ; tput setaf 9;
tar czf $backupPath/$worldname/valheim-backup-$TODAY.tgz $worldpath/$worldname/*
tput setaf 2; echo "$BACKUP_WORLD_MAKING_TAR_COMPLETE" ; tput setaf 9;
sleep 1
tput setaf 2; echo "$BACKUP_WORLD_RESTARTING_SERVICES" ; tput setaf 9;
systemctl start valheimserver_${worldname}.service
tput setaf 2; echo "$BACKUP_WORLD_RESTARTING_SERVICES_1" ; tput setaf 9;
echo ""
tput setaf 2; echo "$BACKUP_WORLD_SET_PERMS_FILES" ; tput setaf 9;
chown -Rf steam:steam ${backupPath}/${worldname}
tput setaf 2; echo "$BACKUP_WORLD_PROCESS_COMPLETE" ; tput setaf 9;
echo ""
else
tput setaf 3; echo "$BACKUP_WORLD_PROCESS_CANCELED" ; tput setaf 9;
fi
}
# Restore World Files DB and FWL
# Thanks to GITHUB @LachlanMac and @Kurt
function restore_world_data() {
#init empty array
declare -a backups
#loop through backups and put in array
for file in ${backupPath}/${worldname}/*.tgz
do
backups=(${backups[*]} "$file")
done;
#counter index
bIndex=1
for item in "${backups[@]}";
do
#print option [index]> [file name]
basefile=$(basename "$item")
echo "$bIndex> ${basefile} "
#increment
bIndex=$((bIndex+1))
done
#promt user for index
tput setaf 2; echo "$RESTORE_WORLD_DATA_HEADER" ; tput setaf 9;
tput setaf 2; echo "$RESTORE_WORLD_DATA_CONFIRM" ; tput setaf 9;
read -p "$RESTORE_WORLD_DATA_SELECTION" selectedIndex
#show confirmation message
restorefile=$(basename "${backups[$selectedIndex-1]}")
echo -ne "
$(ColorRed '------------------------------------------------------------')
$(ColorGreen ' '"$RESTORE_WORLD_DATA_SHOW_FILE"' '${restorefile}' ?')
$(ColorGreen ' '"$RESTORE_WORLD_DATA_ARE_YOU_SURE"' ')
$(ColorOrange ' '"$RESTORE_WORLD_DATA_VALIDATE_DATA_WITH_CONFIG"' '${valheimInstallPath}/${worldname}'/start_valheim_${worldname}.sh')
$(ColorOrange ' '"$RESTORE_WORLD_DATA_INFO"' ')
$(ColorGreen ' '"$RESTORE_WORLD_DATA_CONFIRM_1"' ') "
#read user input confirmation
read -p "" confirmBackupRestore
#if y, then continue, else cancel
if [ "$confirmBackupRestore" == "y" ]; then
#stop valheim server
tput setaf 1; echo "$RESTORE_WORLD_DATA_STOP_VALHEIM_SERVICE" ; tput setaf 9;
systemctl stop valheimserver_${worldname}.service
tput setaf 2; echo "$RESTORE_WORLD_DATA_STOP_VALHEIM_SERVICE_1" ; tput setaf 9;
#give it a few
sleep 5
#copy backup to worlds folder
tput setaf 2; echo "$RESTORE_WORLD_DATA_COPYING ${backups[$selectedIndex-1]} to ${worldpath}/${worldname}/" ; tput setaf 9;
cp ${backups[$selectedIndex-1]} ${worldpath}/${worldname}/
#untar
tput setaf 2; echo "$RESTORE_WORLD_DATA_UNPACKING ${worldpath}/${restorefile}" ; tput setaf 9;
tar xzf ${worldpath}/${worldname}/${restorefile} --strip-components=7 --directory ${worldpath}/${worldname}/
chown -Rf steam:steam ${worldpath}/${worldname}/
rm ${worldpath}/${worldname}/*.tgz
tput setaf 2; echo "$RESTORE_WORLD_DATA_STARTING_VALHEIM_SERVICES" ; tput setaf 9;
tput setaf 2; echo "$RESTORE_WORLD_DATA_CUSS_LOKI" ; tput setaf 9;
systemctl start valheimserver_${worldname}.service
else
tput setaf 2; echo "$RESTORE_WORLD_DATA_CANCEL_CUSS_LOKI" ; tput setaf 9;
fi
}
########################################################################
##########Backup and Restore World DB and FWL Files END#################
########################################################################
########################################################################
###############LD: Download Valheim from steam #########################
########################################################################
function nocheck_valheim_update_install() {
#set_steamexe
tput setaf 1; echo "$INSTALL_BUILD_DOWNLOAD_INSTALL_STEAM_VALHEIM" ; tput setaf 9;
sleep 1
$steamexe +login anonymous +force_install_dir ${valheimInstallPath}/${worldname} +app_update 896660 validate +exit
tput setaf 2; echo "$ECHO_DONE" ; tput setaf 9;
}
########################################################################
#############Install Official Update of Valheim Updates#################
########################################################################
function continue_with_valheim_update_install() {
#set_steamexe