Add optional pre/post install commands to divingbell-apt

Change-Id: I3fdee4b128bfba80bd827fb6a64b800652cdee2f
This commit is contained in:
Mosher, Jaymes (jm616v) 2023-11-20 00:56:51 -07:00
parent 78315ae509
commit 502a74064c
3 changed files with 23 additions and 5 deletions

View File

@ -15,4 +15,4 @@
apiVersion: v1 apiVersion: v1
description: divingbell description: divingbell
name: divingbell name: divingbell
version: 0.1.3 version: 0.1.4

View File

@ -59,6 +59,14 @@ wait_for_dpkg_availability(){
################################################ ################################################
#Stage 1 #Stage 1
#Optional pre-install command
################################################
{{- if .Values.conf.apt.pre_install }}
{{ .Values.conf.apt.pre_install }}
{{- end }}
################################################
#Stage 2
#Collect data #Collect data
################################################ ################################################
@ -68,7 +76,7 @@ load_package_list_with_versions $(dpkg -l | awk 'NR>5 {print $2"="$3}')
declare -A package_info; while read -r name version; do package_info["$name"]="$version N/A N/A"; done < <(dpkg -l | awk '/^ii/ {gsub(/:[^ ]*/, "", $2); print $2, $3}') declare -A package_info; while read -r name version; do package_info["$name"]="$version N/A N/A"; done < <(dpkg -l | awk '/^ii/ {gsub(/:[^ ]*/, "", $2); print $2, $3}')
################################################ ################################################
#Stage 2 #Stage 3
#Add repositories and install/upgrade packages #Add repositories and install/upgrade packages
################################################ ################################################
@ -164,7 +172,7 @@ fi
{{- end }} {{- end }}
################################################ ################################################
#Stage 3 #Stage 4
#Remove packages not present in conf.apt anymore #Remove packages not present in conf.apt anymore
################################################ ################################################
@ -250,7 +258,7 @@ fi
{{- end }} {{- end }}
###################################################### ######################################################
#Stage 4 #Stage 5
#Remove blacklisted packages in conf.apt.blacklistpkgs #Remove blacklisted packages in conf.apt.blacklistpkgs
###################################################### ######################################################
@ -264,7 +272,7 @@ dpkg --configure -a --force-confold,confdef
{{- end }} {{- end }}
###################################################### ######################################################
#Stage 5 #Stage 6
#Verify that all package versions are correct and latest #Verify that all package versions are correct and latest
###################################################### ######################################################
{{- if .Values.conf.apt.upgrade }} {{- if .Values.conf.apt.upgrade }}
@ -301,6 +309,14 @@ for pkg in "${!package_info[@]}"; do
fi fi
done done
{{- end }} {{- end }}
######################################################
#Stage 7
#Run optional post-install command
######################################################
{{- if .Values.conf.apt.post_install }}
{{ .Values.conf.apt.post_install }}
{{- end }}
log.INFO 'Putting the daemon to sleep.' log.INFO 'Putting the daemon to sleep.'
EOF EOF

View File

@ -35,6 +35,8 @@ conf:
- telnetd-ssl - telnetd-ssl
- nis - nis
- ntpdate - ntpdate
pre_install: null
post_install: null
# perm: # perm:
# rerun_policy: always # rerun_policy: always
# 86400 = 1 day # 86400 = 1 day