From 6f78f18c982a2f077f7644834bf9d519dd3892c2 Mon Sep 17 00:00:00 2001 From: Molly Lau Date: Sat, 23 Sep 2023 17:00:29 +0900 Subject: [PATCH] Update autoRepackUbuntuCloudImages.sh --- Linux_reinstall/Ubuntu/autoRepackUbuntuCloudImages.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Linux_reinstall/Ubuntu/autoRepackUbuntuCloudImages.sh b/Linux_reinstall/Ubuntu/autoRepackUbuntuCloudImages.sh index 1893dab..7e2da61 100644 --- a/Linux_reinstall/Ubuntu/autoRepackUbuntuCloudImages.sh +++ b/Linux_reinstall/Ubuntu/autoRepackUbuntuCloudImages.sh @@ -1,7 +1,7 @@ #!/bin/bash # # kpartx and qumu-utils are required -apt install cron kpartx mount qemu-utils -y +apt install cron kpartx mount qemu-utils xz-utils -y # get valid loop device loopDevice=$(echo $(losetup -f)) loopDeviceNum=$(echo $(losetup -f) | cut -d'/' -f 3) @@ -22,14 +22,18 @@ for distName in "jammy" "focal"; do umount /mnt kpartx -dv $loopDevice losetup -d $loopDevice + xz -z -1 -T 0 /root/$fileName.raw + mv /root/$fileName.raw.xz /root/$fileName.xz + rm -rf $websiteDir/$fileName.xz + mv /root/$fileName.xz $websiteDir/$fileName.xz rm -rf $websiteDir/$fileName.raw - mv /root/$fileName.raw $websiteDir/$fileName.raw + rm -rf /root/$fileName.raw rm -rf /root/$fileName.img done done # write crontab task if [[ ! `grep -i "autorepackubuntucloudimages" /etc/crontab` ]]; then - sed -i '$i 30 4 * * 0 root bash /root/autoRepackUbuntuCloudImages.sh' /etc/crontab + sed -i '$i 30 4 10-16,24-30 * 5 root bash /root/autoRepackUbuntuCloudImages.sh' /etc/crontab /etc/init.d/cron restart fi