forked from DGNum/liminix
odhcpc script: mkdir
This commit is contained in:
parent
19212b1eeb
commit
d82173133c
1 changed files with 11 additions and 9 deletions
|
@ -1,12 +1,11 @@
|
||||||
|
|
||||||
(os.chdir (os.getenv "SERVICE_STATE"))
|
(local state-directory (assert (os.getenv "SERVICE_STATE")))
|
||||||
|
(os.execute (.. "mkdir -p " state-directory))
|
||||||
|
|
||||||
(fn write-value [name value]
|
(fn write-value [name value]
|
||||||
(with-open [fout (io.open name :w)]
|
(let [path (.. state-directory "/" name)]
|
||||||
(when value (fout:write value))))
|
(with-open [fout (io.open path :w)]
|
||||||
|
(when value (fout:write value)))))
|
||||||
(write-value "state" (. arg 2))
|
|
||||||
(write-value "ifname" (. arg 1))
|
|
||||||
|
|
||||||
(fn write-value-from-env [name]
|
(fn write-value-from-env [name]
|
||||||
(write-value name (os.getenv (string.upper name))))
|
(write-value name (os.getenv (string.upper name))))
|
||||||
|
@ -47,10 +46,13 @@
|
||||||
(each [_ n (ipairs wanted)]
|
(each [_ n (ipairs wanted)]
|
||||||
(write-value-from-env n)))
|
(write-value-from-env n)))
|
||||||
|
|
||||||
(let [ready (match state
|
(let [[ifname state] arg
|
||||||
|
ready (match state
|
||||||
"started" false
|
"started" false
|
||||||
"unbound" false
|
"unbound" false
|
||||||
"stopped" false
|
"stopped" false
|
||||||
_ true)]
|
_ true)]
|
||||||
(and ready
|
(write-value "state" state)
|
||||||
(with-open [fd (io.open "/proc/self/fd/10" :w)] (fd:write "\n"))))
|
(write-value "ifname" ifname)
|
||||||
|
(when ready
|
||||||
|
(with-open [fd (io.open "/proc/self/fd/10" :w)] (fd:write "\n"))))
|
||||||
|
|
Loading…
Reference in a new issue