summaryrefslogtreecommitdiff
path: root/over/usr/libexec/cydia_/space.sh
diff options
context:
space:
mode:
Diffstat (limited to 'over/usr/libexec/cydia_/space.sh')
-rwxr-xr-xover/usr/libexec/cydia_/space.sh61
1 files changed, 61 insertions, 0 deletions
diff --git a/over/usr/libexec/cydia_/space.sh b/over/usr/libexec/cydia_/space.sh
new file mode 100755
index 000000000..6f3b29ade
--- /dev/null
+++ b/over/usr/libexec/cydia_/space.sh
@@ -0,0 +1,61 @@
+#!/usr/libexec/cydia_/bash
+export PATH=/usr/libexec/cydia_
+
+shopt -s extglob nullglob
+
+function df_() {
+ free=$(df -B1 "$1")
+ free=${free% *%*}
+ free=${free%%*( )}
+ free=${free##* }
+ echo "${free}"
+}
+
+function mv_() {
+ src=$1
+ dst=/var/$(basename "${src}")
+
+ if [[ -e ${dst} ]]; then
+ dst=$(mktemp -d /var/cydia.XXXXXX)
+ else
+ mkdir -p "${dst}"
+ fi
+
+ if [[ -e ${src} ]]; then
+ chmod --reference="${src}" "${dst}"
+ chown --reference="${src}" "${dst}"
+
+ cp -aT "${src}" "${dst}" || {
+ rm -rf "${dst}"
+ exit 1
+ }
+
+ rm -rf "${src}"
+ else
+ chmod 775 "${dst}"
+ chown root.admin "${dst}"
+ fi
+
+ ln -s "${dst}" "${src}"
+}
+
+for dir in \
+ /Applications \
+ /Library/Ringtones \
+ /Library/Wallpaper \
+ /System/Library/Fonts \
+ /usr/share
+do if [[ -d ${dir} && ! -h ${dir} ]]; then
+ used=$(du -bs "${dir}")
+ used=${used%%$'\t'*}
+ free=$(df_ /var)
+
+ if [[ $((used + 524288)) -lt ${free} ]]; then
+ mv_ "${dir}"
+ fi
+elif [[ -h ${dir} && ! -e ${dir} ]]; then
+ rm -f "${dir}"
+ mv_ "${dir}"
+fi; done
+
+[[ $(df_ /) -gt 35651584 && $(df_ /var) -gt 35651584 ]]