Skip to content

Commit 184424d

Browse files
committed
Add scripts error output
1 parent a72441b commit 184424d

File tree

8 files changed

+54
-13
lines changed

8 files changed

+54
-13
lines changed

build-armbian/armbian-files/common-files/usr/sbin/armbian-kernel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ update_script() {
6060
echo -e "${INFO} Start installing update dependencies..."
6161
sudo apt-get update
6262
sudo apt-get install -y subversion
63+
[[ "${?}" -ne "0" ]] && error_msg "The [ subversion ] installation failed."
6364

6465
# Convert script repository address to svn format
6566
if [[ "${script_repo}" == http* && -n "$(echo ${script_repo} | grep "tree/main")" ]]; then
@@ -69,12 +70,14 @@ update_script() {
6970
# Update related files
7071
echo -e "${INFO} Start syncing latest scripts..."
7172
svn export ${script_repo} ${compile_path} --force
73+
[[ "${?}" -ne "0" ]] && error_msg "Sync [ ${script_repo} ] scripts failed."
7274
cp -f ${script_name} ${compile_script}
7375
chmod +x ${compile_script}
7476

7577
# Install dependencies
7678
echo -e "${INFO} Start installing compilation dependencies..."
7779
sudo apt-get install -y $(cat ${script_path}/armbian-compile-kernel-depends)
80+
[[ "${?}" -ne "0" ]] && error_msg "Dependency installation failed."
7881

7982
sync && sleep 3
8083
echo -e "${SUCCESS} Scripts updated successfully."

build-armbian/armbian-files/common-files/usr/sbin/armbian-software

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ update_script() {
213213
# Update related files
214214
echo -e "${STEPS} Start syncing files..."
215215
svn export ${script_repo} ${software_path} --force
216+
[[ "${?}" -ne "0" ]] && error_msg "Sync [ ${script_repo} ] scripts failed."
216217
find ${software_path} -type f -name '*.sh' -exec chmod +x {} \;
217218

218219
sync && sleep 3

build-armbian/armbian-files/common-files/usr/sbin/armbian-swap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,17 @@ create_the_swap() {
9797
# create swapfile
9898
[[ "${ROOTFS_TYPE}" == "btrfs" ]] && {
9999
truncate -s 0 ${SWAP_PATH}/swapfile
100+
[[ "${?}" -ne "0" ]] && error_msg "[ truncate ] operation failed."
100101
chattr +C ${SWAP_PATH}/swapfile
101102
btrfs property set ${SWAP_PATH}/swapfile compression none
102103
}
103104
dd if="/dev/zero" of="${SWAP_PATH}/swapfile" bs="1024" count="$((1048576 * ${swap_gb}))" conv="fsync"
105+
[[ "${?}" -ne "0" ]] && error_msg "Failed to write [ ${SWAP_PATH}/swapfile ] using dd."
104106
chmod 600 ${SWAP_PATH}/swapfile
105107
mkswap -L SWAP ${SWAP_PATH}/swapfile
108+
[[ "${?}" -ne "0" ]] && error_msg "[ mkswap ] operation failed."
106109
swapon ${SWAP_PATH}/swapfile
110+
[[ "${?}" -ne "0" ]] && error_msg "[ swapon ] operation failed."
107111

108112
# Add swap to the mount point
109113
sed -i '/swap/d' /etc/fstab

build-armbian/armbian-files/common-files/usr/sbin/armbian-sync

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ check_depends() {
8383
echo -e "${STEPS} Start installing the necessary dependencies..."
8484
sudo apt-get update
8585
sudo apt-get install -y ${dpkg_packages[*]}
86+
[[ "${?}" -ne "0" ]] && error_msg "Dependency installation failed."
8687
fi
8788
}
8889

@@ -99,24 +100,28 @@ sync_config() {
99100
echo -e "${STEPS} Start syncing operation instruction and service script..."
100101
[[ -d "${sbin_path}" ]] || mkdir -p ${sbin_path}
101102
svn export ${github_repo}/common-files${sbin_path} ${sbin_path} --force
103+
[[ "${?}" -ne "0" ]] && error_msg "Sync [ ${github_repo}/common-files${sbin_path} ] scripts failed."
102104
chmod +x ${sbin_path}/armbian-*
103105

104106
# Update software service related files
105107
echo -e "${STEPS} Start syncing software service script..."
106108
[[ -d "${share_path}" ]] || mkdir -p ${share_path}
107109
svn export ${github_repo}/common-files${share_path} ${share_path} --force
110+
[[ "${?}" -ne "0" ]] && error_msg "Sync [ ${github_repo}/common-files${share_path} ] scripts failed."
108111
find ${share_path} -type f -name '*.sh' -exec chmod +x {} \;
109112

110113
[[ "${PLATFORM}" == "amlogic" ]] && {
111114
# Update operation instruction and service related files
112115
echo -e "${STEPS} Start syncing Amlogic platform specific scripts..."
113116
svn export ${github_repo}/platform-files/amlogic/rootfs${sbin_path} ${sbin_path} --force
117+
[[ "${?}" -ne "0" ]] && error_msg "Sync [ ${github_repo}/platform-files/amlogic/rootfs${sbin_path} ] scripts failed."
114118
chmod +x ${sbin_path}/armbian-*
115119

116120
# Update openvfd related files
117121
echo -e "${STEPS} Start syncing Amlogic platform openvfd service script..."
118122
[[ -d "${openvfd_path}" ]] || mkdir -p ${openvfd_path}
119123
svn export ${github_repo}/platform-files/amlogic/rootfs${openvfd_path} ${openvfd_path} --force
124+
[[ "${?}" -ne "0" ]] && error_msg "Sync [ ${github_repo}/platform-files/amlogic/rootfs${openvfd_path} ] scripts failed."
120125
chmod +x ${openvfd_path}/vfdservice
121126
}
122127

build-armbian/armbian-files/common-files/usr/sbin/armbian-tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,14 @@ EOF
127127

128128
if [[ "${file_system_type}" == "btrfs" ]]; then
129129
mkfs.btrfs -f -U ${ROOTFS_UUID} -L "${LB_PRE}DATA" -m single "/dev/${PT_PRE}3"
130+
[[ "${?}" -eq "0" ]] || error_msg "Failed to format using [ mkfs.btrfs ]"
130131
mount -t btrfs -o compress=zstd:6 "/dev/${PT_PRE}3" "${data_path}"
132+
[[ "${?}" -ne "0" ]] && error_msg "Failed to mount [ /dev/${PT_PRE}3 ] partition."
131133
else
132134
mkfs.ext4 -F -q -U ${ROOTFS_UUID} -L "${LB_PRE}DATA" -b 4k -m 0 "/dev/${PT_PRE}3"
135+
[[ "${?}" -eq "0" ]] || error_msg "Failed to format using [ mkfs.ext4 ]"
133136
mount -t ext4 "/dev/${PT_PRE}3" "${data_path}"
137+
[[ "${?}" -ne "0" ]] && error_msg "Failed to mount [ /dev/${PT_PRE}3 ] partition."
134138
fi
135139

136140
# Add auto mount to /etc/fstab
@@ -149,16 +153,20 @@ expand_current_part() {
149153
echo -e "${STEPS} Install growpart or xfsprogs expansion and formatting tool ... "
150154
apt-get update
151155
apt-get install cloud-guest-utils xfsprogs -y
156+
[[ "${?}" -ne "0" ]] && error_msg "Dependency installation failed."
152157

153158
echo -e "${STEPS} Expansion Partition ... "
154159
growpart /dev/${DISK_NAME} 2
160+
[[ "${?}" -ne "0" ]] && error_msg "[ growpart ] operation failed."
155161

156162
echo -e "${STEPS} Expansion file system ... "
157163
ROOTFS_TYPE="$(df -hT / | grep "/" | awk '{print $2}')"
158164
if [[ "${ROOTFS_TYPE}" == "btrfs" ]]; then
159165
btrfs filesystem resize max /
166+
[[ "${?}" -ne "0" ]] && error_msg "[ btrfs ] operation failed."
160167
else
161168
resize2fs /dev/${ROOT_PTNAME}
169+
[[ "${?}" -ne "0" ]] && error_msg "[ resize2fs ] operation failed."
162170
fi
163171

164172
sync && sleep 3

build-armbian/armbian-files/common-files/usr/sbin/armbian-update

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,27 +256,29 @@ rescue_kernel() {
256256
rm -rf config-* initrd.img-* System.map-* vmlinuz-* uInitrd* *Image dtb*
257257
[[ "${PLATFORM}" == "amlogic" ]] && cp -rf /boot/{u-boot.ext,u-boot.emmc} -t . 2>/dev/null
258258
cp -rf /boot/{*-${kernel_signature},uInitrd,*Image,dtb} -t .
259-
[[ "$?" -ne "0" ]] && error_msg "(1/3) [ boot ] kernel files rescue failed."
259+
[[ "${?}" -ne "0" ]] && error_msg "(1/3) [ boot ] kernel files rescue failed."
260260
echo -e "${INFO} (1/3) [ boot ] kernel files rescue succeeded."
261261

262262
# 02. For /usr/lib/modules/${kernel_signature}
263263
cd ${rescue_path}/rootfs/usr/lib/modules
264264
rm -rf *
265265
cp -rf /usr/lib/modules/${kernel_signature} -t .
266-
[[ "$?" -ne "0" ]] && error_msg "(2/3) [ modules ] kernel files rescue failed."
266+
[[ "${?}" -ne "0" ]] && error_msg "(2/3) [ modules ] kernel files rescue failed."
267267
echo -e "${INFO} (2/3) [ modules ] kernel files rescue succeeded."
268268

269269
# 03. For /usr/src/linux-headers-${kernel_signature}
270270
cd ${rescue_path}/rootfs/usr/src
271271
rm -rf linux-headers-*
272272
cp -rf /usr/src/linux-headers-${kernel_signature} -t .
273-
[[ "$?" -ne "0" ]] && error_msg "(3/3) [ headers ] kernel files rescue failed."
273+
[[ "${?}" -ne "0" ]] && error_msg "(3/3) [ headers ] kernel files rescue failed."
274274
echo -e "${INFO} (3/3) [ headers ] kernel files rescue succeeded."
275275

276276
# Unmount the emmc partition
277277
cd ${rescue_path}
278278
umount -f ${rescue_path}/bootfs
279+
[[ "${?}" -ne "0" ]] && error_msg "Failed to umount [ ${rescue_path}/bootfs ]"
279280
umount -f ${rescue_path}/rootfs
281+
[[ "${?}" -ne "0" ]] && error_msg "Failed to umount [ ${rescue_path}/rootfs ]"
280282

281283
sync && echo ""
282284
}
@@ -401,6 +403,7 @@ backup_kernel() {
401403
# 1. Pack the boot-*.tar.gz file
402404
rm -rf *
403405
cp -rf /boot/*-${current_kernel_signature} -t .
406+
[[ "${?}" -ne "0" ]] && error_msg "(1/4) Failed to copy [ /boot/*-${current_kernel_signature} ] files."
404407
rm -rf dtb*
405408
chmod +x *
406409
tar -czf boot-${current_kernel_signature}.tar.gz *
@@ -410,20 +413,23 @@ backup_kernel() {
410413
# 2. Pack the dtb-*.tar.gz file
411414
rm -rf *
412415
cp -rf /boot/dtb/${PLATFORM}/* -t .
416+
[[ "${?}" -ne "0" ]] && error_msg "(2/4) Failed to copy [ /boot/dtb/${PLATFORM}/* ] files."
413417
tar -czf dtb-${PLATFORM}-${current_kernel_signature}.tar.gz *
414418
mv -f *.tar.gz ${backup_path}/${current_kernel}
415419
echo -e "${INFO} (2/4) The [ dtb-${PLATFORM}-${current_kernel_signature}.tar.gz ] backup successful."
416420

417421
# 3. Pack the header-*.tar.gz file
418422
rm -rf *
419423
cp -rf /usr/src/linux-headers-${current_kernel_signature}/* -t .
424+
[[ "${?}" -ne "0" ]] && error_msg "(3/4) Failed to copy [ /usr/src/linux-headers-${current_kernel_signature}/* ] files."
420425
tar -czf header-${current_kernel_signature}.tar.gz *
421426
mv -f *.tar.gz ${backup_path}/${current_kernel}
422427
echo -e "${INFO} (3/4) The [ header-${current_kernel_signature}.tar.gz ] backup successful."
423428

424429
# 4. Pack the modules-*.tar.gz file
425430
rm -rf *
426431
cp -rf /usr/lib/modules/${current_kernel_signature} -t .
432+
[[ "${?}" -ne "0" ]] && error_msg "(4/4) Failed to copy [ /usr/lib/modules/${current_kernel_signature} ] files."
427433
tar -czf modules-${current_kernel_signature}.tar.gz *
428434
mv -f *.tar.gz ${backup_path}/${current_kernel}
429435
echo -e "${INFO} (4/4) The [ modules-${current_kernel_signature}.tar.gz ] backup successful."
@@ -507,6 +513,7 @@ update_uboot() {
507513
dd if="${BOOTLOADER_IMG}" of="${DEV_EMMC}" conv=fsync bs=1 count=444 2>/dev/null
508514
dd if="${BOOTLOADER_IMG}" of="${DEV_EMMC}" conv=fsync bs=512 skip=1 seek=1 2>/dev/null
509515
fi
516+
[[ "${?}" -eq "0" ]] || error_msg "Failed to write bootloader using [ dd ]."
510517

511518
sync && echo ""
512519
}

build-armbian/armbian-files/platform-files/amlogic/rootfs/usr/sbin/armbian-install

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,9 @@ create_partition() {
327327
[[ -d "/usr/lib/u-boot" ]] || mkdir -p /usr/lib/u-boot
328328
MYBOX_UBOOT="/usr/lib/u-boot/mybox-bootloader.img"
329329
[[ -f "${MYBOX_UBOOT}" ]] && rm -f ${MYBOX_UBOOT}
330-
echo -e "${INFO} Start backup default bootloader."
330+
echo -e "${INFO} Start backing up the default bootloader."
331331
dd if="${DEV_EMMC}" of="${MYBOX_UBOOT}" bs=1M count=4 conv=fsync
332+
[[ "${?}" -eq "0" ]] || error_msg "Using dd to backup [ ${MYBOX_UBOOT} ] failed."
332333

333334
# Clear emmc disk data
334335
exists_pts="$(parted ${DEV_EMMC} print 2>/dev/null | grep 'primary' | wc -l)"
@@ -339,7 +340,7 @@ create_partition() {
339340
let i++
340341
done
341342
fi
342-
dd if=/dev/zero of=${DEV_EMMC} bs=512 count=1 conv=fsync
343+
#dd if=/dev/zero of=${DEV_EMMC} bs=512 count=1 conv=fsync
343344

344345
# Use the ampart partition tool
345346
AMPART_STATUS="no"
@@ -388,6 +389,7 @@ create_partition() {
388389
parted -s "${DEV_EMMC}" mklabel msdos
389390
parted -s "${DEV_EMMC}" mkpart primary fat32 $((BLANK1))MiB $((BLANK1 + BOOT - 1))MiB
390391
parted -s "${DEV_EMMC}" mkpart primary ${file_system_type} $((BLANK1 + BOOT + BLANK2))MiB 100%
392+
[[ "${?}" -eq "0" ]] || error_msg "Failed to create partition using [ parted ]."
391393

392394
# Write bootloader
393395
if [[ -n "${MAINLINE_UBOOT}" && -f "/usr/lib/u-boot/${MAINLINE_UBOOT}" && "${auto_mainline_uboot}" == "yes" ]]; then
@@ -399,28 +401,32 @@ create_partition() {
399401
dd if="/usr/lib/u-boot/${BOOTLOADER_IMG}" of="${DEV_EMMC}" conv=fsync bs=1 count=444
400402
dd if="/usr/lib/u-boot/${BOOTLOADER_IMG}" of="${DEV_EMMC}" conv=fsync bs=512 skip=1 seek=1
401403
elif [[ -n "${MYBOX_UBOOT}" && -f "${MYBOX_UBOOT}" ]]; then
402-
echo -e "${INFO} Restore the mybox bootloader: [ ${MYBOX_UBOOT} ]"
404+
echo -e "${INFO} Write the mybox bootloader: [ ${MYBOX_UBOOT} ]"
403405
dd if="${MYBOX_UBOOT}" of="${DEV_EMMC}" conv=fsync bs=1 count=444
404406
dd if="${MYBOX_UBOOT}" of="${DEV_EMMC}" conv=fsync bs=512 skip=1 seek=1
405407
fi
408+
[[ "${?}" -eq "0" ]] || error_msg "Failed to write bootloader using [ dd ]."
406409
}
407410

408411
# Copy bootfs partition files
409412
copy_bootfs() {
410413
cd /
411-
echo -e "${STEPS} Start processing the bootfs partition..."
414+
echo -e "${STEPS} Start processing the BOOTFS partition..."
412415

413416
PART_BOOT="${DEV_EMMC}p1"
414417

415418
if grep -q ${PART_BOOT} /proc/mounts; then
416419
echo -e "${INFO} Unmounting BOOT partiton."
417420
umount -f ${PART_BOOT}
421+
[[ "${?}" -eq "0" ]] || error_msg "Failed to umount [ ${PART_BOOT} ]."
418422
fi
419-
echo -e "${INFO} Formatting BOOTFS partition."
423+
424+
echo -e "${INFO} Start formatting BOOTFS partition..."
420425
mkfs.vfat -F 32 -n "BOOT_EMMC" ${PART_BOOT}
426+
[[ "${?}" -eq "0" ]] || error_msg "Failed to format using [ mkfs.vfat ]."
421427

422428
mount -o rw ${PART_BOOT} ${DIR_INSTALL}
423-
[[ "$?" -ne "0" ]] && error_msg "Failed to mount BOOTFS partition"
429+
[[ "${?}" -ne "0" ]] && error_msg "Failed to mount BOOTFS partition."
424430

425431
echo -e "${INFO} Start copy BOOTFS partition data."
426432
cp -rf /boot/* ${DIR_INSTALL}
@@ -475,6 +481,7 @@ EOF
475481

476482
sync && sleep 3
477483
umount -f ${DIR_INSTALL}
484+
[[ "${?}" -eq "0" ]] || error_msg "Failed to umount [ ${DIR_INSTALL} ]."
478485
}
479486

480487
# Copy rootfs partition files
@@ -487,19 +494,23 @@ copy_rootfs() {
487494
if grep -q ${PART_ROOT} /proc/mounts; then
488495
echo -e "${INFO} Unmounting ROOT partiton."
489496
umount -f ${PART_ROOT}
497+
[[ "${?}" -eq "0" ]] || error_msg "Failed to umount [ ${PART_ROOT} ]."
490498
fi
491499

492-
echo -e "${INFO} Formatting ROOTFS partition."
500+
echo -e "${INFO} Start formatting ROOTFS partition..."
493501
if [[ "${file_system_type}" == "btrfs" ]]; then
494502
mkfs.btrfs -f -U ${ROOTFS_UUID} -L "ROOTFS_EMMC" -m single ${PART_ROOT}
495-
sleep 3
503+
[[ "${?}" -eq "0" ]] || error_msg "Failed to format using [ mkfs.btrfs ]"
504+
496505
mount -t btrfs -o compress=zstd:6 ${PART_ROOT} ${DIR_INSTALL}
506+
[[ "${?}" -ne "0" ]] && error_msg "Failed to mount ROOTFS partition."
497507
else
498508
mkfs.ext4 -F -q -U ${ROOTFS_UUID} -L "ROOTFS_EMMC" -b 4k -m 0 ${PART_ROOT}
499-
sleep 3
509+
[[ "${?}" -eq "0" ]] || error_msg "Failed to format using [ mkfs.ext4 ]"
510+
500511
mount -t ext4 ${PART_ROOT} ${DIR_INSTALL}
512+
[[ "${?}" -ne "0" ]] && error_msg "Failed to mount ROOTFS partition."
501513
fi
502-
[[ "$?" -ne "0" ]] && error_msg "Failed to mount ROOTFS partition"
503514

504515
echo -e "${INFO} Start copy ROOTFS partition data."
505516
# Create relevant directories
@@ -574,6 +585,7 @@ EOF
574585

575586
sync && sleep 3
576587
umount -f ${DIR_INSTALL}
588+
[[ "${?}" -eq "0" ]] || error_msg "Failed to umount [ ${DIR_INSTALL} ]."
577589
}
578590

579591
# Check script permission

build-armbian/armbian-files/platform-files/amlogic/rootfs/usr/sbin/armbian-led

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ do_update_conf() {
6464
echo -e "${STEPS} Start syncing files..."
6565
[[ -d "${openvfd_path}" ]] || mkdir -p ${openvfd_path}
6666
svn export ${openvfd_repo} ${openvfd_path} --force
67+
[[ "${?}" -ne "0" ]] && error_msg "Sync [ ${openvfd_repo} ] scripts failed."
6768
chmod +x ${openvfd_path}/vfdservice
6869

6970
sync && sleep 3

0 commit comments

Comments
 (0)