summaryrefslogtreecommitdiff
path: root/over/usr/libexec/cydia_/install.sh
blob: 5c1d85d3d0e20c7228df74c2ae609309ddf176ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/libexec/cydia_/bash

shopt -s extglob nullglob
export PATH=/usr/libexec/cydia_

function df_() {
    free=$(df -B1 "$1")
    free=${free% *%*}
    free=${free%%*( )}
    free=${free##* }
    echo "${free}"
}

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
        base=$(basename "${dir}")

        new=/var/${base}
        if [[ -e ${new} ]]; then
            new=$(godmode mktemp -d cydia.XXXXXX)
        fi

        godmode mv -T "${dir}" "${new}"
        godmode ln -s "${new}" "${dir}"
    fi
fi; done

[[ $(df_ /) -gt 35651584 && $(df_ /var) -gt 35651584 ]]