-
Notifications
You must be signed in to change notification settings - Fork 0
/
push-updates
executable file
·46 lines (38 loc) · 1.02 KB
/
push-updates
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
39
40
41
42
43
44
45
46
#!/bin/bash
script_dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
cd "$script_dir"
while read source; do
case "$source" in
*skel*|*cron*)
;;
*)
echo "ignoring $source"
continue
;;
esac
target="/$source"
user="$(stat --printf %G "$target" 2>/dev/null)"
group="$user"
if [[ ${_o_os_mac} == "yes" ]]; then
if [[ $(id -u) == "0" ]]; then
user="root"
group="staff"
fi
fi
targetdir="${target%/*}"
if ! [[ -d "$targetdir" ]];then
echo "mkdir -p $targetdir"
mkdir -p "$targetdir"
fi
if [[ -h $source ]]; then
#copy symlinks into dir
echo "discoverd symlink switch target to dir"
target="$targetdir"
fi
echo "copy ./${source} -> ${target} ($user)"
rsync -avhq "$source" "$target" || { echo "operation failed"; exit 1; }
if [[ -n "$user" ]]; then
chown -R "$user:$group" "${target}"
fi
echo
done < <(git ls-tree --name-only -r HEAD)