@@ -31,101 +31,58 @@ fn_fix_msg_end() {
31
31
fi
32
32
}
33
33
34
+ fn_exists_fix () {
35
+ local short=" ${1:? } "
36
+
37
+ if [ " $( type -t " fix_${short} .sh" ) " == ' function' ]; then
38
+ return 0
39
+ else
40
+ return 1
41
+ fi
42
+ }
43
+
44
+ fn_apply_fix () {
45
+ local phase_message=" ${1:? } "
46
+ local short=" ${2:? } "
47
+
48
+ if fn_exists_fix " ${short} " ; then
49
+ " fix_${short} .sh"
50
+ else
51
+ fn_print_error_nl " ${shortname} is marked to apply pre start fix but there is no fix registered"
52
+ fi
53
+ }
54
+
55
+ apply_pre_start_fix=(arma3 armar ark av bt bo csgo cmw dst hw ins nmrih onset rust rw sdtd sfc sof2 squad st tf2 terraria ts3 mcb mta unt vh wurm zmr)
56
+ apply_post_install_fix=(av kf kf2 lo ro samp ut2k4 ut ut3)
57
+
58
+ # validate registered fixes for safe development
59
+ for fix in " ${apply_pre_start_fix[@]} " " ${apply_post_install_fix[@]} " ; do
60
+ if ! fn_exists_fix " ${fix} " ; then
61
+ fn_print_fail_nl " fix_${fix} .sh is registered but doesn't exist. Typo or did you miss to modify core_functions.sh?"
62
+ exitcode 1
63
+ core_exit.sh
64
+ fi
65
+ done
66
+
34
67
# Fixes that are run on start.
35
68
if [ " ${commandname} " != " INSTALL" ] && [ -z " ${fixbypass} " ]; then
36
69
if [ " ${appid} " ]; then
37
70
fix_steamcmd.sh
38
71
fi
39
72
40
- if [ " ${shortname} " == " arma3" ]; then
41
- fix_arma3.sh
42
- elif [ " ${shortname} " == " armar" ]; then
43
- fix_armar.sh
44
- elif [ " ${shortname} " == " ark" ]; then
45
- fix_ark.sh
46
- elif [ " ${shortname} " == " av" ]; then
47
- fix_av.sh
48
- elif [ " ${shortname} " == " bt" ]; then
49
- fix_bt.sh
50
- elif [ " ${shortname} " == " bo" ]; then
51
- fix_bo.sh
52
- elif [ " ${shortname} " == " csgo" ]; then
53
- fix_csgo.sh
54
- elif [ " ${shortname} " == " cmw" ]; then
55
- fix_cmw.sh
56
- elif [ " ${shortname} " == " dst" ]; then
57
- fix_dst.sh
58
- elif [ " ${shortname} " == " hw" ]; then
59
- fix_hw.sh
60
- elif [ " ${shortname} " == " ins" ]; then
61
- fix_ins.sh
62
- elif [ " ${shortname} " == " nmrih" ]; then
63
- fix_nmrih.sh
64
- elif [ " ${shortname} " == " onset" ]; then
65
- fix_onset.sh
66
- elif [ " ${shortname} " == " rust" ]; then
67
- fix_rust.sh
68
- elif [ " ${shortname} " == " rw" ]; then
69
- fix_rw.sh
70
- elif [ " ${shortname} " == " sdtd" ]; then
71
- fix_sdtd.sh
72
- elif [ " ${shortname} " == " sfc" ]; then
73
- fix_sfc.sh
74
- elif [ " ${shortname} " == " sof2" ]; then
75
- fix_sof2.sh
76
- elif [ " ${shortname} " == " squad" ]; then
77
- fix_squad.sh
78
- elif [ " ${shortname} " == " st" ]; then
79
- fix_st.sh
80
- elif [ " ${shortname} " == " tf2" ]; then
81
- fix_tf2.sh
82
- elif [ " ${shortname} " == " terraria" ]; then
83
- fix_terraria.sh
84
- elif [ " ${shortname} " == " ts3" ]; then
85
- fix_ts3.sh
86
- elif [ " ${shortname} " == " mcb" ]; then
87
- fix_mcb.sh
88
- elif [ " ${shortname} " == " mta" ]; then
89
- fix_mta.sh
90
- elif [ " ${shortname} " == " unt" ]; then
91
- fix_unt.sh
92
- elif [ " ${shortname} " == " vh" ]; then
93
- fix_vh.sh
94
- elif [ " ${shortname} " == " wurm" ]; then
95
- fix_wurm.sh
96
- elif [ " ${shortname} " == " zmr" ]; then
97
- fix_zmr.sh
73
+ if grep -qEe " (^|\s)${shortname} (\s|$)" <<< " ${apply_pre_start_fix[@]}" ; then
74
+ fn_apply_fix " pre start" " ${shortname} "
98
75
fi
99
76
fi
100
77
101
78
# Fixes that are run on install only.
102
79
if [ " ${commandname} " == " INSTALL" ]; then
103
- if [ " ${shortname} " == " av " ] || [ " ${shortname} " == " cmw " ] || [ " ${shortname} " == " kf " ] || [ " ${shortname} " == " kf2 " ] || [ " ${shortname} " == " lo " ] || [ " ${shortname} " == " onset " ] || [ " ${shortname} " == " ro " ] || [ " ${shortname} " == " samp " ] || [ " ${shortname} " == " ut2k4 " ] || [ " ${shortname} " == " ut " ] || [ " ${shortname} " == " ut3 " ] ; then
80
+ if grep -qEe " (^|\s) ${shortname} (\s|$) " <<< " ${apply_post_install_fix[@]} " ; then
104
81
echo -e " "
105
82
echo -e " ${lightyellow} Applying Post-Install Fixes${default} "
106
83
echo -e " ================================="
107
84
fn_sleep_time
108
85
postinstall=1
109
- if [ " ${shortname} " == " av" ]; then
110
- fix_av.sh
111
- elif [ " ${shortname} " == " kf" ]; then
112
- fix_kf.sh
113
- elif [ " ${shortname} " == " kf2" ]; then
114
- fix_kf2.sh
115
- elif [ " ${shortname} " == " lo" ]; then
116
- fix_lo.sh
117
- elif [ " ${shortname} " == " ro" ]; then
118
- fix_ro.sh
119
- elif [ " ${shortname} " == " samp" ]; then
120
- fix_samp.sh
121
- elif [ " ${shortname} " == " ut2k4" ]; then
122
- fix_ut2k4.sh
123
- elif [ " ${shortname} " == " ut" ]; then
124
- fix_ut.sh
125
- elif [ " ${shortname} " == " ut3" ]; then
126
- fix_ut3.sh
127
- else
128
- fn_print_information_nl " No fixes required."
129
- fi
86
+ fn_apply_fix " post install" " ${shortname} "
130
87
fi
131
88
fi
0 commit comments