代码拉取完成,页面将自动刷新
同步操作将从 MJ PC Lab/Shell Utility 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/bash
#rsync files from ISO image into directory
#examples
#
#rsync all files/sub directories from iso into a directory
#cpiso dvd.iso /tmp/dvd/
#
#rsync all files/sub directories under a specified directory from iso into a directory
#cpiso dvd.iso:pareht/directory/ /tmp/dvd/
#
#rsync a single file from iso into a directory
#cpiso dvd.iso:path/to/file /tmp/dvd/
if [ $# -lt 2 ]; then
echo "Usage: $(basename $0) <ISO File>[:parent/directory] <Target Directory>" >&2;
exit 1;
fi
colonPos=$(expr index "$1" ':');
if [ $colonPos -eq 0 ]; then
colonPos=$(expr length "$1");
colonPos=$[colonPos+1];
fi;
isoPathLength=$[colonPos-1];
image=${1:0:isoPathLength};
if [ ! -f "$image" ]; then
echo "\"$image\" is no a file." >&2;
hasError=1;
fi;
rawSource=${1:colonPos}
if [ "${rawSource:0:1}" == '/' ]; then
rawSource=${rawSource##/};
fi;
if [ -z "$rawSource" ]; then
rawSource='.';
fi;
rawTarget="$2";
if [ ${rawTarget:0:1} != "/" ]; then
pwd=$(pwd);
if [ "$pwd" == "/" ]; then
target="$pwd""$rawTarget";
else
target="$pwd"/"$rawTarget";
fi;
else
target="$rawTarget";
fi;
if [ ! -d "$target" ]; then
echo "\"$rawTarget\" is no a directory." >&2;
hasError=1;
fi;
if [ $hasError ]; then
exit 2;
fi;
tempdir=$(mktemp -d);
mount -o loop,ro "$image" "$tempdir";
if [ $? -ne 0 ]; then
rmdir "$tempdir";
echo 'Mount image failed.' >&2;
exit 3;
fi;
pushd "$tempdir" &> /dev/null;
if [ ! -e "$rawSource" ]; then
popd &> /dev/null;
umount "$tempdir";
rmdir "$tempdir";
echo 'Source directory not exists.' >&2;
exit 4;
elif [ -d "$rawSource" ]; then
pushd "$rawSource" &> /dev/null;
rsync -a --delete ./ "$target";
popd &> /dev/null;
elif [ -f "$rawSource" ]; then
cp "$rawSource" "$target";
fi;
popd &> /dev/null;
umount "$tempdir";
rmdir "$tempdir";
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。