33
33
# ##########################################################
34
34
# System
35
35
# ##########################################################
36
- function debian_upgrade {
36
+ debian_upgrade () {
37
37
printf " Running initial updates - This will take a while...\n"
38
- DEBIAN_FRONTEND=noninteractive apt-get -y upgrade > /dev/null
38
+ (
39
+ export DEBIAN_FRONTEND=noninteractive
40
+ apt-get update > /dev/null && > /dev/null apt upgrade -y
41
+ )
39
42
}
40
- function system_update {
41
- case " ${ detected_distro[ family]} " in
43
+ system_update () {
44
+ case " ` detected_distro family` " in
42
45
' debian' )
43
46
# Force IPv4 and noninteractive upgrade after script runs to prevent
44
47
# breaking nf_conntrack
@@ -51,13 +54,13 @@ function system_update {
51
54
# Run initial updates for RedHat-based systems, quietly
52
55
# Also, add the 'epel-release' repository to yum
53
56
printf " Running initial updates - This will take a while...\n"
54
- yum --quiet -y update > /dev/null
55
- yum --quiet -y install epel-release > /dev/null
56
- yum --quiet repolist
57
+ dnf --quiet -y update > /dev/null
58
+ dnf --quiet -y install epel-release > /dev/null
59
+ dnf --quiet repolist
57
60
;;
58
61
esac
59
62
}
60
- function system_primary_ip {
63
+ system_primary_ip () {
61
64
local ip_address=" $( ip a | awk ' /inet / {print $2}' ) "
62
65
echo $ip_address | cut -d' ' -f 2 | cut -d/ -f 1
63
66
}
@@ -115,7 +118,7 @@ detect_distro() {
115
118
' /etc/os-release` "
116
119
117
120
local version=" ` awk -F= '
118
- $1 ~ /VERSION_ID/ {
121
+ $1 ~ /^ VERSION_ID$ / {
119
122
$2=gensub(/^"(.+)"/, "\\1", 1, $2);
120
123
print $2
121
124
}
@@ -862,15 +865,26 @@ function certbot_ssl {
862
865
# OS Detection Stuff
863
866
# ##########################################################
864
867
# Store detected distribution information in a globally-scoped Associative Array
865
- readonly dist=" $( detect_distro ' distro' ) "
866
- readonly fam=" $( detect_distro ' family' ) "
867
- readonly -A detected_distro=" (
868
- [distro]=" ${dist,,} " \
869
- [family]=" ${fam,,} " \
870
- [version]=" $( detect_distro ' version' ) "
871
- [version_major]=" $( detect_distro ' version' | cut -d. -f1) "
872
- [version_minor]=" $( detect_distro ' version' | cut -d. -f2) "
873
- )"
868
+ readonly distro=" ` detect_distro ' distro' | tr [:upper:] [:lower:]` "
869
+ readonly family=" ` detect_distro ' family' | tr [:upper:] [:lower:]` "
870
+ readonly version=" ` detect_dstro ' version' ` "
871
+ readonly version_major=" ` echo $version | cut -d. -f1` "
872
+ readonly version_minor=" ` echo $version | cut -d. -f2` "
873
+
874
+ detected_distro (){
875
+ eval echo \$ $1
876
+ }
877
+
878
+ # CAN'T USE ASSOCIATIVE ARRAYS IN POSIX SH
879
+
880
+ # readonly -A detected_distro="(
881
+ # [distro]="${dist,,}" \
882
+ # [family]="${fam,,}" \
883
+ # [version]="$(detect_distro 'version')"
884
+ # [version_major]="$(detect_distro 'version' | cut -d. -f1)"
885
+ # [version_minor]="$(detect_distro 'version' | cut -d. -f2)"
886
+ # )"
887
+
874
888
# ##########################################################
875
889
# Other functions
876
890
# ##########################################################
0 commit comments