add --onchange to __file, because having to use __config_file just for that feels redundant
This commit is contained in:
parent
59bff81735
commit
c6fd43da81
3 changed files with 15 additions and 1 deletions
|
@ -23,7 +23,7 @@ destination="/$__object_id"
|
||||||
state_should="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
type="$(cat "$__object/explorer/type")"
|
type="$(cat "$__object/explorer/type")"
|
||||||
stat_file="$__object/explorer/stat"
|
stat_file="$__object/explorer/stat"
|
||||||
|
fire_onchange=''
|
||||||
|
|
||||||
get_current_value() {
|
get_current_value() {
|
||||||
if [ -s "$stat_file" ]; then
|
if [ -s "$stat_file" ]; then
|
||||||
|
@ -45,16 +45,19 @@ get_current_value() {
|
||||||
set_group() {
|
set_group() {
|
||||||
echo "chgrp '$1' '$destination'"
|
echo "chgrp '$1' '$destination'"
|
||||||
echo "chgrp '$1'" >> "$__messages_out"
|
echo "chgrp '$1'" >> "$__messages_out"
|
||||||
|
fire_onchange=1
|
||||||
}
|
}
|
||||||
|
|
||||||
set_owner() {
|
set_owner() {
|
||||||
echo "chown '$1' '$destination'"
|
echo "chown '$1' '$destination'"
|
||||||
echo "chown '$1'" >> "$__messages_out"
|
echo "chown '$1'" >> "$__messages_out"
|
||||||
|
fire_onchange=1
|
||||||
}
|
}
|
||||||
|
|
||||||
set_mode() {
|
set_mode() {
|
||||||
echo "chmod '$1' '$destination'"
|
echo "chmod '$1' '$destination'"
|
||||||
echo "chmod '$1'" >> "$__messages_out"
|
echo "chmod '$1'" >> "$__messages_out"
|
||||||
|
fire_onchange=1
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
|
@ -83,6 +86,7 @@ case "$state_should" in
|
||||||
if [ "$type" = "file" ]; then
|
if [ "$type" = "file" ]; then
|
||||||
echo "rm -f '$destination'"
|
echo "rm -f '$destination'"
|
||||||
echo remove >> "$__messages_out"
|
echo remove >> "$__messages_out"
|
||||||
|
fire_onchange=1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
@ -91,3 +95,9 @@ case "$state_should" in
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/onchange" ]; then
|
||||||
|
if [ -n "$fire_onchange" ]; then
|
||||||
|
cat "$__object/parameter/onchange"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
|
@ -63,6 +63,9 @@ source
|
||||||
If not supplied, an empty file or directory will be created.
|
If not supplied, an empty file or directory will be created.
|
||||||
If source is '-' (dash), take what was written to stdin as the file content.
|
If source is '-' (dash), take what was written to stdin as the file content.
|
||||||
|
|
||||||
|
onchange
|
||||||
|
The code to run if file is modified.
|
||||||
|
|
||||||
MESSAGES
|
MESSAGES
|
||||||
--------
|
--------
|
||||||
chgrp <group>
|
chgrp <group>
|
||||||
|
|
|
@ -3,3 +3,4 @@ group
|
||||||
mode
|
mode
|
||||||
owner
|
owner
|
||||||
source
|
source
|
||||||
|
onchange
|
||||||
|
|
Loading…
Reference in a new issue