summarylogtreecommitdiffstats
path: root/sweethome3d-3dmodels-blendswap-ccby.install
blob: 9c9bc0246e38f1c5ec332fa08a2b43408d591ffb (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
set -eu
user_path=".eteks/sweethome3d/furniture/"

# arg 1:  the new package version
post_install() {
    find /home/* -maxdepth 0 -type d \! -user root -print0 | while IFS= read -r -d '' user_home; do
        mkdir -p "${user_home}/${user_path}"
        for lib in /usr/share/eteks/sweethome3d/furniture/3dmodels-blendswap-ccby/*.sh3f; do
            ln -s "$lib" "${user_home}/${user_path}/"
        done
        chown --no-dereference --preserve-root --recursive --reference="${user_home}" "${user_home}/${user_path}"
    done
}

# arg 1:  the old package version
pre_remove() {
    find /home/* -maxdepth 0 -type d \! -user root -print0 | while IFS= read -r -d '' user_home; do
        rm -f "${user_home}/${user_path}/3dmodels-blendswap-ccby-*.sh3f"
        (
            cd "${user_home}"
            if [ -d "${user_path}" ]; then
                rmdir --ignore-fail-on-non-empty -p "${user_path}"
            fi
        )
    done
}