-
Notifications
You must be signed in to change notification settings - Fork 203
/
fix-attrs
executable file
·66 lines (64 loc) · 1.62 KB
/
fix-attrs
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/execlineb -P
/bin/export PATH /usr/bin:/bin
/bin/export recfunction "\
foreground { s6-chown -u ${3} -g ${4} -- ${1} }
foreground
{
ifelse { s6-test -d ${1} }
{
if -t { s6-test ! ${6} = "-" }
s6-chmod ${6} ${1}
}
if -t { s6-test ! ${5} = "-" }
s6-chmod ${5} ${1}
}
if -t { if { s6-${2} } s6-test -d ${1} }
forbacktickx -0 subfile
{
backtick -D 0 -n S6_FIX_ATTRS_HIDDEN { printcontenv S6_FIX_ATTRS_HIDDEN }
importas S6_FIX_ATTRS_HIDDEN S6_FIX_ATTRS_HIDDEN
ifelse { s6-test ${S6_FIX_ATTRS_HIDDEN} -eq 0 } { s6-ls -0 ${1} }
s6-ls -0 -a ${1}
}
multisubstitute
{
importas -u subfile subfile
importas recfunction recfunction
}
execlineb -S6 -c ${recfunction} ${1}/${subfile} true ${3} ${4} ${5} ${6}"
# process each line
forstdin -d"\n" -- line
importas -u line line
if { s6-test -n ${line} }
multidefine -0 -Cd" \t" -- ${line} { globex recurse userentry fmode dmode }
# get 'uid' and 'gid'
multidefine -Cd"," -- ${userentry} { account uidgid }
backtick -n envuidgid_opts
{
backtick -n opts
{
ifte { s6-echo -- -D${uidgid} } { s6-echo -- -i }
s6-test -n ${uidgid}
}
importas -u opts opts
ifte { s6-echo -- -nB ${opts} } { s6-echo -- ${opts} }
pipeline { s6-echo ${account} }
if
{
redirfd -w 1 /dev/null
fdmove -c 2 1
s6-grep -- ":"
}
}
importas -u -sCd" \t" envuidgid_opts envuidgid_opts
s6-envuidgid ${envuidgid_opts} ${account}
importas -u uid UID
importas -u gid GID
elglob -0 -- files ${globex}
forx -p -- file { ${files} }
multisubstitute
{
importas -u file file
importas recfunction recfunction
}
execlineb -S6 -c ${recfunction} ${file} ${recurse} ${uid} ${gid} ${fmode} ${dmode}