#!/bin/sh

#bin/sh脚本下，很多指令不生效且会直接导致退出，所以status查询，数字计算等都不可在这类脚本中执行
#后续可以考虑通过传入参数执行挂载


refs=$1

mountOtherPath()
{
	mount --bind /run /root/run
	mount --bind /sys /root/sys
	mount --bind /proc /root/proc
	mount /dev/nvme0n1p2 /root/boot
	mount /dev/nvme0n1p5 /root/data
	mount /dev/nvme0n1p4 /root/backup
}


umountOtherPath()
{
	umount /root/proc >>$PLOGFILE
	umount /root/run >>$PLOGFILE
	umount /root/sys >>$PLOGFILE
	umount /root/boot >>$PLOGFILE
	umount /root/data >>$PLOGFILE
	umount /root/backup >>$PLOGFILE
}

mountOtherPath
PLOGFILE=/root/data/.backup/log/deploy.log

chroot /root /bin/sh -c "/usr/lib/ostree/ostree-remount" >> $PLOGFILE
#chroot /root /bin/sh -c "ostree admin deploy "kylin:kylin/desktop/v11/2603/xc/general/all/rc4/amd64"  --os="kylin" --retain" >> $PLOGFILE
chroot /root /bin/sh -c "ostree admin deploy $refs  --os="kylin" --retain" >> $PLOGFILE

umountOtherPath
