# Don't re-create if old config already looks good. In this case, init_done should be preserved. TODO: rename lc register to lc init, then should I remove this behavior??
if[[-f"$fname"]];then
...
...
@@ -128,26 +128,26 @@ function lci_overwrite_conf () {
[["$oldpath"="$newpath"]]&&return 0
fi
echo-e"#autogenerated config, could be overwritten without warning.\nmasterconf=$newpath" | tee"$fname"> /dev/null || err "lci_overwrite_conf: unable to create $fname"||return$?
echo-e"#autogenerated config, could be overwritten without warning.\nmasterconf=$newpath" | tee"$fname"> /dev/null ||lcf_err "lci_overwrite_conf: unable to create $fname"||return$?
chmod ugo+rw "$fname"
}
function lci_register (){
local confpath="$1"
[[-f"$confpath"]]|| die "lci_register: $confpath not exist"
[[-f"$confpath"]]||lcf_die "lci_register: $confpath not exist"
# For new register (or register a different dir), clear all existing conf. This will trigger init again.
lci_overwrite_conf /etc/linuxconf.conf "$confpath"|| die "lci_register cannot write new conf"
lci_overwrite_conf /etc/linuxconf.conf "$confpath"||lcf_die "lci_register cannot write new conf"
}
function lci_call (){
# calls an lc function in masterconf (and included subconf)
["$1"=""]&& die "logic error: lci_call without arg"
["$1"=""]&&lcf_die "logic error: lci_call without arg"
export LCI_SUBSHELL_OP="$1"
local masterconf="$(lci_conf_get_masterconf_path /etc/linuxconf.conf)"|| die "unable to call lc_init. Cannot read masterconf path from /etc/linuxconf.conf"
local masterconf="$(lci_conf_get_masterconf_path /etc/linuxconf.conf)"||lcf_die "unable to call lc_init. Cannot read masterconf path from /etc/linuxconf.conf"
local workdir="$(dirname"$masterconf")"
cd"$workdir"|| die "unable to enter config directory: $workdir"
cd"$workdir"||lcf_die "unable to enter config directory: $workdir"
lc_include "$masterconf"
export LCI_SUBSHELL_OP=__lc_operation_undefined
}
...
...
@@ -158,7 +158,7 @@ function lci_init_if_needed () {
lci_call lc_init
lci_state_file_append /etc/linuxconf.conf init_done "$uname"|| die "lc_init functions succeeded, but unable to update /etc/linuxconf.conf"
lci_state_file_append /etc/linuxconf.conf init_done "$uname"||lcf_die "lc_init functions succeeded, but unable to update /etc/linuxconf.conf"
}
function lci_startup_if_needed (){
...
...
@@ -166,20 +166,20 @@ function lci_startup_if_needed () {
local state_file="/tmp/.linuxconf-state-$uname"
if[[!-f$state_file]];then
touch$state_file&&chmod ugo+rw $state_file|| die "failed to create tmp file $state_file"
touch$state_file&&chmod ugo+rw $state_file||lcf_die "failed to create tmp file $state_file"