Skip to content

Commit 34942d7

Browse files
committed
updated with some error checking
1 parent 8ee6fce commit 34942d7

2 files changed

Lines changed: 23 additions & 15 deletions

File tree

autorun/init.arch.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,26 +134,31 @@ enable_services() {
134134
}
135135

136136
config_initcpio() {
137-
local -i exit_n=0
137+
local -i errors=0
138138
submsg "Updating mkinitcpio"
139139
# add extra modules from local file
140140
initcpio_modules+=" "
141141
initcpio_modules+=${EXTRAINTMODULES}
142-
sed -i s/"MODULES=()"/"MODULES=(${initcpio_modules})"/g /etc/mkinitcpio.conf || exit_n+=1
143-
mkinitcpio -p ${KERNEL} || exit_n+=1
144-
return ${exit_n}
142+
sed -i s/"MODULES=()"/"MODULES=(${initcpio_modules})"/g /etc/mkinitcpio.conf || errors+=1
143+
mkinitcpio -p ${KERNEL} || errors+=1
144+
145+
[ ${errors} -ne 0 ] && return 1
146+
return 0
145147
}
146148

147149
config_misc() {
150+
local -i errors=0
148151
submsg "Misc Config"
149-
touch /etc/machine-id
152+
touch /etc/machine-id || errors+=1
150153
# Use timezone module to set Timezone from config
151154
rm -f /etc/localtime
152155
ln -sf "/usr/share/zoneinfo/${TIMEZONE}" /etc/localtime
153156
if [ ${?} -ne 0 ];then
154157
warn "Could not set timezone: ${TIMEZONE}, check that it exists"
155-
return 1
158+
errors+=1
156159
fi
160+
[ ${errors} -ne 0 ] && return 1
161+
return 0
157162
}
158163

159164
run_user_script(){

autorun/init.debian.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
# Name of kernel package
77
KERNEL="linux-image"
88

9-
# Name of bootloader. As of now, only syslinux is supported
9+
# Name of bootloader. As of now, only extlinux is supported
1010
#BOOTLOADER="grub"??
11+
BOOTLOADER="extlinux"
1112

1213
## /DEFAULTS ##
1314

@@ -157,24 +158,26 @@ enable_services() {
157158

158159
config_initramdisk() {
159160
submsg "Reconfiguring Kernel and Rebuilding Initial Ramdisk"
160-
local exit_n=0
161-
dpkg-reconfigure --frontend=noninteractive ${KERNEL} || exit_n+=${?}
162-
update-initramfs -u || exit_n+=${?}
161+
local -i errors=0
162+
dpkg-reconfigure --frontend=noninteractive ${KERNEL} || errors+=1
163+
update-initramfs -u || errors+=1
163164

164165
[ ${exit_n} -ne 0 ] && return 1
165166
return 0
166167
}
167168

168169
config_misc() {
169170
submsg "Misc Config"
170-
touch /etc/machine-id
171+
local -i errors=0
172+
touch /etc/machine-id || errors+=1
171173
# Use timezone module to set Timezone from config
172-
rm -f /etc/localtime
173174
ln -sf "/usr/share/zoneinfo/${TIMEZONE}" /etc/localtime
174175
if [ ${?} -ne 0 ];then
175176
warn "Could not set timezone: ${TIMEZONE}, check that it exists"
176-
return 1
177+
errors+=1
177178
fi
179+
[ ${errors} -ne 0 ] && return 1
180+
return 0
178181
}
179182

180183
run_user_script(){
@@ -197,12 +200,12 @@ main() {
197200
source /etc/profile
198201
if [ -f "${local_config}" ];then
199202
message "parsing ${local_config}"
200-
parse_environment "${local_config}"
203+
parse_environment "${local_config}" || exit_code+=1
201204
else
202205
warn "${local_config} does not exist, this should be auto-generated by gen_cloud_template.sh"
203206
fi
204207

205-
dpkg-reconfigure --frontend=noninteractive ${BOOTLOADER}
208+
dpkg-reconfigure --frontend=noninteractive ${BOOTLOADER} || exit_code+=1
206209
case ${BOOTLOADER} in
207210
*extlinux*)
208211
install_extlinux

0 commit comments

Comments
 (0)