diff --git a/Commands.md b/Commands.md index 4ff1299..faca6d2 100644 --- a/Commands.md +++ b/Commands.md @@ -7,6 +7,13 @@ xzname=$imgname.xz sizes=sizes-$imgname-$xzame.txt checksums=sha256sum-$imgname-$xzname.sha256 +# get real username (not root) if run with sudo +if [ ! -z $SUDO_USER ]; then + username=$SUDO_USER +else + username=$USER +fi + lsblk echo "Enter disk name (including /dev/) ex /dev/sdb" read dadisk @@ -18,13 +25,21 @@ webhook "Copied the disk to $imgname ($imgsize), compressing to $xzname" sudo pishrink.sh -v -Z -a $imgname xzsize=$(du -h $xzname) -webhook "$imgname ($imgsize) shrunk to $xzname ($xzsize), calculating sha256 checksums..." true +webhook "$imgname ($imgsize) shrunk to $xzname ($xzsize), calculating sha256 checksums..." sha256sum $imgname | tee $checksums sha256sum $xzname | tee -a $checksums webhook "getting sizes" echo -e "imgsize: $imgsize\nxzsize: $xzsize" | tee $sizes +echo "changing perms" +sudo chown $username:$username $xzname + +webhook "testing archive $xzname" +xz -t $xzname +ret=$? +webhook "test status: $ret" + webhook "DONE\n\tdisk: $dadisk\n\timgname: $imgname ($imgsize)\n\txzname: $xzname ($xzsize)" true sudo shutdown -r +1 ```