# 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??
# 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
if[[-f"$fname"]];then
...
@@ -131,26 +131,26 @@ function lci_overwrite_conf () {
...
@@ -131,26 +131,26 @@ function lci_overwrite_conf () {
[["$oldpath"="$newpath"]]&&return 0
[["$oldpath"="$newpath"]]&&return 0
fi
fi
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$?
echo-e"#autogenerated config, could be overwritten without warning.\nmasterconf=$newpath" | tee"$fname"> /dev/null || lc_err "lci_overwrite_conf: unable to create $fname"||return$?
chmod ugo+rw "$fname"
chmod ugo+rw "$fname"
}
}
function lci_register (){
function lci_register (){
local confpath="$1"
local confpath="$1"
[[-f"$confpath"]]|| lcf_die "lci_register: $confpath not exist"
[[-f"$confpath"]]|| lc_die "lci_register: $confpath not exist"
# For new register (or register a different dir), clear all existing conf. This will trigger init again.
# For new register (or register a different dir), clear all existing conf. This will trigger init again.
lci_overwrite_conf /etc/linuxconf.conf "$confpath"|| lcf_die "lci_register cannot write new conf"
lci_overwrite_conf /etc/linuxconf.conf "$confpath"|| lc_die "lci_register cannot write new conf"
}
}
function lci_call (){
function lci_call (){
# calls an lc function in masterconf (and included subconf)
# calls an lc function in masterconf (and included subconf)
["$1"=""]&& lcf_die "logic error: lci_call without arg"
["$1"=""]&& lc_die "logic error: lci_call without arg"
export LCI_SUBSHELL_OP="$1"
export LCI_SUBSHELL_OP="$1"
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 masterconf="$(lci_conf_get_masterconf_path /etc/linuxconf.conf)"|| lc_die "unable to call lc_init. Cannot read masterconf path from /etc/linuxconf.conf"
local workdir="$(dirname"$masterconf")"
local workdir="$(dirname"$masterconf")"
cd"$workdir"|| lcf_die "unable to enter config directory: $workdir"
cd"$workdir"|| lc_die "unable to enter config directory: $workdir"
lc_include "$masterconf"
lc_include "$masterconf"
export LCI_SUBSHELL_OP=__lc_operation_undefined
export LCI_SUBSHELL_OP=__lc_operation_undefined
}
}
...
@@ -161,7 +161,7 @@ function lci_init_if_needed () {
...
@@ -161,7 +161,7 @@ function lci_init_if_needed () {
lci_call lc_init
lci_call lc_init
lci_state_file_append /etc/linuxconf.conf init_done "$uname"|| lcf_die "lc_init functions succeeded, but unable to update /etc/linuxconf.conf"
lci_state_file_append /etc/linuxconf.conf init_done "$uname"|| lc_die "lc_init functions succeeded, but unable to update /etc/linuxconf.conf"
}
}
function lci_startup_if_needed (){
function lci_startup_if_needed (){
...
@@ -169,20 +169,20 @@ function lci_startup_if_needed () {
...
@@ -169,20 +169,20 @@ function lci_startup_if_needed () {
local state_file="/tmp/.linuxconf-state-$uname"
local state_file="/tmp/.linuxconf-state-$uname"
if[[!-f$state_file]];then
if[[!-f$state_file]];then
touch$state_file&&chmod ugo+rw $state_file|| lcf_die "failed to create tmp file $state_file"
touch$state_file&&chmod ugo+rw $state_file|| lc_die "failed to create tmp file $state_file"