X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/aa5e5990e17da617b0e95c962e86924bc9b99b50..03191d515b8474764cc2a34dcc2284fcd158bce6:/Library/move.sh?ds=inline diff --git a/Library/move.sh b/Library/move.sh index 0b9e09d2..1e9dbb22 100755 --- a/Library/move.sh +++ b/Library/move.sh @@ -2,6 +2,13 @@ shopt -s extglob nullglob +if [[ ${1:0:1} == - ]]; then + v=$1 + shift 1 +else + v= +fi + function df_() { free=$(df -B1 "$1") free=${free% *%*} @@ -13,32 +20,51 @@ function df_() { function mv_() { src=$1 - mkdir -p /var/stash - dst=$(mktemp -d /var/stash/$(basename "${src}").XXXXXX) + if [[ ! -e /var/stash ]]; then + mkdir -p /var/db/stash + /usr/libexec/cydia/setnsfpn /var/db/stash + ln -s -t /var /var/db/stash + elif [[ -d /var/stash ]]; then + /usr/libexec/cydia/setnsfpn /var/stash + fi + + tmp=$(mktemp -d /var/stash/_.XXXXXX) + dst=${tmp}/${src##*/} + + chmod 755 "${tmp}" + chown root.admin "${tmp}" + + mkdir -- "${dst}" || { + rmdir -- "${tmp}" + exit 1 + } + + echo -n "${src}" >"${tmp}.lnk" if [[ -e ${src} ]]; then chmod --reference="${src}" "${dst}" chown --reference="${src}" "${dst}" - cp -aT "${src}" "${dst}" || { - rm -rf "${dst}" + cp -aT $v "${src}" "${dst}" || { + rm -rf "${tmp}" exit 1 } - rm -rf "${src}" + mv $v "${src}" "${src}.moved" + ln -s "${dst}" "${src}" + rm -rf $v "${src}.moved" else chmod 775 "${dst}" chown root.admin "${dst}" + ln -s "${dst}" "${src}" fi - - ln -s "${dst}" "${src}" } function shift_() { - dir=$1 + dir=${1%/} if [[ -d ${dir} && ! -h ${dir} ]]; then - used=$(du -bs "${dir}") + used=$(/usr/libexec/cydia/du -bs "${dir}") used=${used%%$'\t'*} free=$(df_ /var)