]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[UTILS] FSGET: Use `/etc/apt/auth.conf.d/*.conf` for APT auth fsget-auth 2844/head
authors3rj1k <evasive.gyron@gmail.com>
Fri, 11 Jul 2025 18:52:22 +0000 (20:52 +0200)
committers3rj1k <evasive.gyron@gmail.com>
Fri, 11 Jul 2025 18:52:22 +0000 (20:52 +0200)
scripts/packaging/fsget.sh

index 049e5085b82ddea43cb8d87e29598809f00894f7..580b7032ff24d778adebce800bf776605e61596d 100755 (executable)
@@ -31,15 +31,26 @@ setup_common()
                grep
 }
 
+disable_global_auth()
+{
+       local auth_file="/etc/apt/auth.conf"
+
+       if [ -f "${auth_file}" ]; then
+               sed -i 's/^machine \(freeswitch\.signalwire\.com\|fsa\.freeswitch\.com\)/# machine \1/' "${auth_file}"
+       fi
+}
+
 configure_auth()
 {
        local domain=$1
        local username=${2:-signalwire}
        local token=$3
-       if ! grep -q "machine ${domain}" /etc/apt/auth.conf; then
-               echo "machine ${domain} login ${username} password ${token}" >> /etc/apt/auth.conf
-               chmod 600 /etc/apt/auth.conf
-       fi
+       local auth_file="/etc/apt/auth.conf.d/${domain}.conf"
+
+       mkdir -p /etc/apt/auth.conf.d
+
+       echo "machine ${domain} login ${username} password ${token}" > "${auth_file}"
+       chmod 600 "${auth_file}"
 }
 
 install_freeswitch()
@@ -99,11 +110,12 @@ if [ "${ID,,}" = "debian" ]; then
                echo "FreeSWITCH Community ($RELEASE)"
 
                setup_common
+               disable_global_auth
                configure_auth "${DOMAIN}" "" "${TOKEN}"
 
                curl \
                        --fail \
-                       --netrc-file /etc/apt/auth.conf \
+                       --netrc-file "/etc/apt/auth.conf.d/${DOMAIN}.conf" \
                        --output ${GPG_KEY} \
                        https://${DOMAIN}/repo/deb/${RPI}debian-release/signalwire-freeswitch-repo.gpg
 
@@ -132,11 +144,12 @@ if [ "${ID,,}" = "debian" ]; then
                echo "FreeSWITCH Enterprise ($RELEASE)"
 
                setup_common
+               disable_global_auth
                configure_auth "${DOMAIN}" "" "${TOKEN}"
 
                curl \
                        --fail \
-                       --netrc-file /etc/apt/auth.conf \
+                       --netrc-file "/etc/apt/auth.conf.d/${DOMAIN}.conf" \
                        --output ${GPG_KEY} \
                        https://${DOMAIN}/repo/deb/fsa${RPI}/keyring.gpg