3131# Exit immediately if a command fails
3232set -e
3333
34+ APTVARS=" NEEDRESTART_MODE=l NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive"
3435if ! command -v realpath & > /dev/null; then
3536 echo " Package \" coreutils\" not found, installing..."
36- sudo apt-get install -y coreutils
37+ sudo $APTVARS apt-get install -y coreutils
3738fi
3839
3940SCRIPT_DIR=$( dirname " $( realpath " $0 " ) " )
@@ -43,6 +44,53 @@ cd "$SCRIPT_DIR"
4344if ! command -v yq & > /dev/null; then
4445 sudo " $SCRIPT_DIR /install_scripts/./install_yq.sh"
4546fi
47+ # Check that the correct version of yq is installed
48+ if ! yq --version 2> /dev/null | grep -q ' https://github\.com/mikefarah/yq' ; then
49+ echo " ERROR: Detected an incompatible yq installation."
50+ echo " Please ensure the Python yq is uninstalled with \" pip uninstall -y yq\" , then re-run this script."
51+ exit 1
52+ fi
53+
54+ echo " Parsing options.yaml..."
55+ # Check if the YAML file exists, if not, set and save default values
56+ if [ ! -f " options.yaml" ]; then
57+ echo " # Upon modification, apply changes with ./generate_configurations.sh." >> " options.yaml"
58+ echo " " >> " options.yaml"
59+ echo " # Configure the MCC/MNC and TAC" >> " options.yaml"
60+ echo " plmn: 00101" >> " options.yaml"
61+ echo " tac: 7" >> " options.yaml"
62+ echo " " >> " options.yaml"
63+ echo " # Configure the DNN/APN" >> " options.yaml"
64+ echo " dnn: nist-dnn" >> " options.yaml"
65+ echo " " >> " options.yaml"
66+ echo " # Configure the Single Network Slice Selection Assistance Information (S-NSSAI)" >> " options.yaml"
67+ echo " sst: 1" >> " options.yaml"
68+ echo " sd: FFFFFF" >> " options.yaml"
69+ echo " " >> " options.yaml"
70+ echo " # If false, AMF will use the default 127.0.0.5, true: it will use the hostname IP" >> " options.yaml"
71+ echo " expose_amf_over_hostname: false" >> " options.yaml"
72+ echo " " >> " options.yaml"
73+ echo " # Toggle whether or not to include the Security Edge Protection Proxies (SEPP1 and SEPP2)" >> " options.yaml"
74+ echo " include_sepp: false" >> " options.yaml"
75+ echo " " >> " options.yaml"
76+ echo " # Configure the ogstun gateway address for UE traffic" >> " options.yaml"
77+ echo " ogstun_ipv4: 10.45.0.0/16" >> " options.yaml"
78+ echo " ogstun_ipv6: 2001:db8:cafe::/48" >> " options.yaml"
79+ echo " " >> " options.yaml"
80+ echo " ogstun2_ipv4: 10.46.0.0/16" >> " options.yaml"
81+ echo " ogstun2_ipv6: 2001:db8:babe::/48" >> " options.yaml"
82+ echo " " >> " options.yaml"
83+ echo " ogstun3_ipv4: 10.47.0.0/16" >> " options.yaml"
84+ echo " ogstun3_ipv6: 2001:db8:face::/48" >> " options.yaml"
85+ echo " " >> " options.yaml"
86+ echo " # The use of systemctl can be disabled to support installations within Docker. Before changing this value, it is recommended to uninstall the testbed." >> " options.yaml"
87+ echo " use_systemctl: true" >> " options.yaml"
88+ fi
89+
90+ USE_SYSTEMCTL=$( yq eval ' .use_systemctl' options.yaml)
91+ if [[ " $USE_SYSTEMCTL " == " null" || -z " $USE_SYSTEMCTL " ]]; then
92+ USE_SYSTEMCTL=" true" # Default
93+ fi
4694
4795# Check for open5gs-amfd and open5gs-upfd binaries to determine if Open5GS is already installed
4896if [ -f " open5gs/install/bin/open5gs-amfd" ] && [ -f " open5gs/install/bin/open5gs-upfd" ]; then
@@ -59,39 +107,43 @@ INSTALL_START_TIME=$(date +%s)
59107sudo rm -rf logs/
60108
61109# Prevent the unattended-upgrades service from creating dpkg locks that would error the script
62- if systemctl is-active --quiet unattended-upgrades; then
63- sudo systemctl stop unattended-upgrades & > /dev/null && echo " Successfully stopped unattended-upgrades service."
64- sudo systemctl disable unattended-upgrades & > /dev/null && echo " Successfully disabled unattended-upgrades service."
65- fi
66- if systemctl is-active --quiet apt-daily.timer; then
67- sudo systemctl stop apt-daily.timer & > /dev/null && echo " Successfully stopped apt-daily.timer service."
68- sudo systemctl disable apt-daily.timer & > /dev/null && echo " Successfully disabled apt-daily.timer service."
69- fi
70- if systemctl is-active --quiet apt-daily-upgrade.timer; then
71- sudo systemctl stop apt-daily-upgrade.timer & > /dev/null && echo " Successfully stopped apt-daily-upgrade.timer service."
72- sudo systemctl disable apt-daily-upgrade.timer & > /dev/null && echo " Successfully disabled apt-daily-upgrade.timer service."
110+ if [[ " $USE_SYSTEMCTL " == " true" ]]; then
111+ if systemctl is-active --quiet unattended-upgrades; then
112+ sudo systemctl stop unattended-upgrades & > /dev/null && echo " Successfully stopped unattended-upgrades service."
113+ sudo systemctl disable unattended-upgrades & > /dev/null && echo " Successfully disabled unattended-upgrades service."
114+ fi
115+ if systemctl is-active --quiet apt-daily.timer; then
116+ sudo systemctl stop apt-daily.timer & > /dev/null && echo " Successfully stopped apt-daily.timer service."
117+ sudo systemctl disable apt-daily.timer & > /dev/null && echo " Successfully disabled apt-daily.timer service."
118+ fi
119+ if systemctl is-active --quiet apt-daily-upgrade.timer; then
120+ sudo systemctl stop apt-daily-upgrade.timer & > /dev/null && echo " Successfully stopped apt-daily-upgrade.timer service."
121+ sudo systemctl disable apt-daily-upgrade.timer & > /dev/null && echo " Successfully disabled apt-daily-upgrade.timer service."
122+ fi
73123fi
74124
75125if [ ! -d " open5gs" ]; then
76126 echo " Cloning Open5GS..."
77127 ./install_scripts/git_clone.sh https://github.com/open5gs/open5gs.git
78128fi
129+
79130cd $SCRIPT_DIR /open5gs
80131
81132echo
82133echo
83134echo " Installing Open5GS..."
84- export DEBIAN_FRONTEND=noninteractive
85135# Modifies the needrestart configuration to suppress interactive prompts
86- if [ -f " /etc/needrestart/needrestart.conf" ]; then
87- if ! grep -q " ^\$ nrconf{restart} = 'a';$" " /etc/needrestart/needrestart.conf" ; then
88- sudo sed -i " /\$ nrconf{restart} = /c\$ nrconf{restart} = 'a';" " /etc/needrestart/needrestart.conf"
89- echo " Modified needrestart configuration to auto-restart services."
90- fi
136+ if [ -d /etc/needrestart ]; then
137+ sudo install -d -m 0755 /etc/needrestart/conf.d
138+ sudo tee /etc/needrestart/conf.d/99-no-auto-restart.conf > /dev/null << 'EOF '
139+ # Disable automatic restarts during apt operations
140+ $nrconf{restart} = 'l';
141+ EOF
142+ echo " Configured needrestart to list-only (no service restarts)."
91143fi
92- export NEEDRESTART_SUSPEND=1
93144
94145sudo " $SCRIPT_DIR /./install_scripts/install_mongodb.sh"
146+ sudo " $SCRIPT_DIR /./install_scripts/start_mongodb.sh"
95147
96148# Check and create the open5gs user and group if they don't exist
97149if ! getent passwd open5gs > /dev/null; then
@@ -107,11 +159,11 @@ sudo usermod -a -G open5gs open5gs
107159echo " Installing dependencies for building Open5GS..."
108160
109161# Code from (https://open5gs.org/open5gs/docs/guide/02-building-open5gs-from-sources#building-open5gs):
110- sudo apt-get install -y python3-pip python3-setuptools python3-wheel ninja-build build-essential flex bison git cmake libsctp-dev libgnutls28-dev libgcrypt-dev libssl-dev libmongoc-dev libbson-dev libyaml-dev libnghttp2 -dev libmicrohttpd-dev libcurl4-gnutls-dev libnghttp2-dev libtins-dev libtalloc-dev meson
162+ sudo $APTVARS apt-get install -y python3-pip python3-setuptools python3-wheel ninja-build build-essential flex bison git cmake libsctp-dev libgnutls28-dev libgcrypt-dev libssl-dev libmongoc-dev libbson-dev libyaml-dev libmicrohttpd-dev libcurl4-gnutls-dev libnghttp2-dev libtins-dev libtalloc-dev meson
111163if apt-cache show libidn-dev > /dev/null 2>&1 ; then
112- sudo apt-get install -y --no-install-recommends libidn-dev
164+ sudo $APTVARS apt-get install -y --no-install-recommends libidn-dev
113165else
114- sudo apt-get install -y --no-install-recommends libidn11-dev
166+ sudo $APTVARS apt-get install -y --no-install-recommends libidn11-dev
115167fi
116168
117169rm -rf build
0 commit comments