Re: [yocto] [PATCH] update-rc.d: support enable/disable function
Ping On 12/5/18 4:13 PM, Changqing Li wrote: ping On 11/26/18 11:35 AM, Changqing Li wrote: Ping On 11/9/18 5:44 PM, changqing...@windriver.com wrote: From: Changqing Li Add support of enable/disable function, so that user can keep previous config after upgrade package Signed-off-by: Changqing Li --- update-rc.d | 70 + 1 file changed, 70 insertions(+) diff --git a/update-rc.d b/update-rc.d index e07cf85..1ba97d3 100644 --- a/update-rc.d +++ b/update-rc.d @@ -27,6 +27,7 @@ usage() usage: update-rc.d [-n] [-f] [-r ] remove update-rc.d [-n] [-r ] [-s] defaults [NN | sNN kNN] update-rc.d [-n] [-r ] [-s] start|stop NN runlvl [runlvl] [...] . + update-rc.d [-n] [-r ] [-s] enable|disable [S|2|3|4|5] -n: not really -f: force -v: verbose @@ -101,6 +102,43 @@ makelinks() done } +renamelink() +{ + local oldstartstop newstartstop lev oldnn newnn + if [ "x$1" = "xS" ]; then + oldstartstop="K" + newstartstop="S" + else + oldstartstop="S" + newstartstop="K" + fi + + lev=$2 + if ls ${etcd}${lev}.d/${oldstartstop}*${bn} >/dev/null 2>&1; then + oldnn=`basename ${etcd}${lev}.d/${oldstartstop}*${bn}|cut -c2-3` + newnn=$[100-$oldnn] + [ $verbose -eq 1 ] && echo "rename ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} -> ${etcd}${lev}.d/${newstartstop}${newnn}${bn}" + if [ $notreally -eq 0 ];then + mv ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} ${etcd}${lev}.d/${newstartstop}${newnn}${bn} + fi + if [ $dostart -eq 1 ] && [ $newstartstop = "S" ] && [ $lev = $RUNLEVEL ]; then + $fn start || true + fi + fi + +} + +renamelinks() +{ + if [ $# -eq 2 ]; then + renamelink $1 $2 + else + for i in 2 3 4 5 S; do + renamelink $1 $i + done + fi +} + while [ $# -gt 0 ]; do case $1 in -n) notreally=1 @@ -221,6 +259,13 @@ case $1 in ;; start | stop) + if [ $# -lt 4 ] + then + echo "Not enough arguments" + usage + exit 1 + fi + while [ $# -gt 0 ]; do if [ $1 = "start" ]; then letter=S @@ -251,6 +296,31 @@ case $1 in makelinks ;; + enable | disable) + if [ $1 = "enable" ]; then + letter=S + elif [ $1 = "disable" ]; then + letter=K + else + usage + exit 1 + fi + shift + if [ $# -gt 0 ] + then + case $1 in + S|2|3|4|5) + renamelinks $letter $1 + ;; + *) + usage + exit 1 + ;; + esac + else + renamelinks $letter + fi + ;; *) usage exit 1 -- BRs Sandy(Li Changqing) -- ___ yocto mailing list yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/yocto
Re: [yocto] [PATCH] update-rc.d: support enable/disable function
ping On 11/26/18 11:35 AM, Changqing Li wrote: Ping On 11/9/18 5:44 PM, changqing...@windriver.com wrote: From: Changqing Li Add support of enable/disable function, so that user can keep previous config after upgrade package Signed-off-by: Changqing Li --- update-rc.d | 70 + 1 file changed, 70 insertions(+) diff --git a/update-rc.d b/update-rc.d index e07cf85..1ba97d3 100644 --- a/update-rc.d +++ b/update-rc.d @@ -27,6 +27,7 @@ usage() usage: update-rc.d [-n] [-f] [-r ] remove update-rc.d [-n] [-r ] [-s] defaults [NN | sNN kNN] update-rc.d [-n] [-r ] [-s] start|stop NN runlvl [runlvl] [...] . + update-rc.d [-n] [-r ] [-s] enable|disable [S|2|3|4|5] -n: not really -f: force -v: verbose @@ -101,6 +102,43 @@ makelinks() done } +renamelink() +{ + local oldstartstop newstartstop lev oldnn newnn + if [ "x$1" = "xS" ]; then + oldstartstop="K" + newstartstop="S" + else + oldstartstop="S" + newstartstop="K" + fi + + lev=$2 + if ls ${etcd}${lev}.d/${oldstartstop}*${bn} >/dev/null 2>&1; then + oldnn=`basename ${etcd}${lev}.d/${oldstartstop}*${bn}|cut -c2-3` + newnn=$[100-$oldnn] + [ $verbose -eq 1 ] && echo "rename ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} -> ${etcd}${lev}.d/${newstartstop}${newnn}${bn}" + if [ $notreally -eq 0 ];then + mv ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} ${etcd}${lev}.d/${newstartstop}${newnn}${bn} + fi + if [ $dostart -eq 1 ] && [ $newstartstop = "S" ] && [ $lev = $RUNLEVEL ]; then + $fn start || true + fi + fi + +} + +renamelinks() +{ + if [ $# -eq 2 ]; then + renamelink $1 $2 + else + for i in 2 3 4 5 S; do + renamelink $1 $i + done + fi +} + while [ $# -gt 0 ]; do case $1 in -n) notreally=1 @@ -221,6 +259,13 @@ case $1 in ;; start | stop) + if [ $# -lt 4 ] + then + echo "Not enough arguments" + usage + exit 1 + fi + while [ $# -gt 0 ]; do if [ $1 = "start" ]; then letter=S @@ -251,6 +296,31 @@ case $1 in makelinks ;; + enable | disable) + if [ $1 = "enable" ]; then + letter=S + elif [ $1 = "disable" ]; then + letter=K + else + usage + exit 1 + fi + shift + if [ $# -gt 0 ] + then + case $1 in + S|2|3|4|5) + renamelinks $letter $1 + ;; + *) + usage + exit 1 + ;; + esac + else + renamelinks $letter + fi + ;; *) usage exit 1 -- BRs Sandy(Li Changqing) -- ___ yocto mailing list yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/yocto
Re: [yocto] [PATCH] update-rc.d: support enable/disable function
Ping On 11/9/18 5:44 PM, changqing...@windriver.com wrote: From: Changqing Li Add support of enable/disable function, so that user can keep previous config after upgrade package Signed-off-by: Changqing Li --- update-rc.d | 70 + 1 file changed, 70 insertions(+) diff --git a/update-rc.d b/update-rc.d index e07cf85..1ba97d3 100644 --- a/update-rc.d +++ b/update-rc.d @@ -27,6 +27,7 @@ usage() usage: update-rc.d [-n] [-f] [-r ] remove update-rc.d [-n] [-r ] [-s] defaults [NN | sNN kNN] update-rc.d [-n] [-r ] [-s] start|stop NN runlvl [runlvl] [...] . + update-rc.d [-n] [-r ] [-s] enable|disable [S|2|3|4|5] -n: not really -f: force -v: verbose @@ -101,6 +102,43 @@ makelinks() done } +renamelink() +{ + local oldstartstop newstartstop lev oldnn newnn + if [ "x$1" = "xS" ]; then + oldstartstop="K" + newstartstop="S" + else + oldstartstop="S" + newstartstop="K" + fi + + lev=$2 + if ls ${etcd}${lev}.d/${oldstartstop}*${bn} >/dev/null 2>&1; then + oldnn=`basename ${etcd}${lev}.d/${oldstartstop}*${bn}|cut -c2-3` + newnn=$[100-$oldnn] + [ $verbose -eq 1 ] && echo "rename ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} -> ${etcd}${lev}.d/${newstartstop}${newnn}${bn}" + if [ $notreally -eq 0 ];then + mv ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} ${etcd}${lev}.d/${newstartstop}${newnn}${bn} + fi + if [ $dostart -eq 1 ] && [ $newstartstop = "S" ] && [ $lev = $RUNLEVEL ]; then + $fn start || true + fi + fi + +} + +renamelinks() +{ + if [ $# -eq 2 ]; then + renamelink $1 $2 + else + for i in 2 3 4 5 S; do + renamelink $1 $i + done + fi +} + while [ $# -gt 0 ]; do case $1 in -n) notreally=1 @@ -221,6 +259,13 @@ case $1 in ;; start | stop) + if [ $# -lt 4 ] + then + echo "Not enough arguments" + usage + exit 1 + fi + while [ $# -gt 0 ]; do if [ $1 = "start" ]; then letter=S @@ -251,6 +296,31 @@ case $1 in makelinks ;; + enable | disable) + if [ $1 = "enable" ]; then + letter=S + elif [ $1 = "disable" ]; then + letter=K + else + usage + exit 1 + fi + shift + if [ $# -gt 0 ] + then + case $1 in + S|2|3|4|5) + renamelinks $letter $1 + ;; + *) + usage + exit 1 + ;; + esac + else + renamelinks $letter + fi + ;; *) usage exit 1 -- BRs Sandy(Li Changqing) -- ___ yocto mailing list yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/yocto
[yocto] [PATCH] update-rc.d: support enable/disable function
From: Changqing Li Add support of enable/disable function, so that user can keep previous config after upgrade package Signed-off-by: Changqing Li --- update-rc.d | 70 + 1 file changed, 70 insertions(+) diff --git a/update-rc.d b/update-rc.d index e07cf85..1ba97d3 100644 --- a/update-rc.d +++ b/update-rc.d @@ -27,6 +27,7 @@ usage() usage: update-rc.d [-n] [-f] [-r ] remove update-rc.d [-n] [-r ] [-s] defaults [NN | sNN kNN] update-rc.d [-n] [-r ] [-s] start|stop NN runlvl [runlvl] [...] . + update-rc.d [-n] [-r ] [-s] enable|disable [S|2|3|4|5] -n: not really -f: force -v: verbose @@ -101,6 +102,43 @@ makelinks() done } +renamelink() +{ + local oldstartstop newstartstop lev oldnn newnn + if [ "x$1" = "xS" ]; then + oldstartstop="K" + newstartstop="S" + else + oldstartstop="S" + newstartstop="K" + fi + + lev=$2 + if ls ${etcd}${lev}.d/${oldstartstop}*${bn} >/dev/null 2>&1; then + oldnn=`basename ${etcd}${lev}.d/${oldstartstop}*${bn}|cut -c2-3` + newnn=$[100-$oldnn] + [ $verbose -eq 1 ] && echo "rename ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} -> ${etcd}${lev}.d/${newstartstop}${newnn}${bn}" + if [ $notreally -eq 0 ];then + mv ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} ${etcd}${lev}.d/${newstartstop}${newnn}${bn} + fi + if [ $dostart -eq 1 ] && [ $newstartstop = "S" ] && [ $lev = $RUNLEVEL ]; then + $fn start || true + fi + fi + +} + +renamelinks() +{ + if [ $# -eq 2 ]; then + renamelink $1 $2 + else + for i in 2 3 4 5 S; do + renamelink $1 $i + done + fi +} + while [ $# -gt 0 ]; do case $1 in -n) notreally=1 @@ -221,6 +259,13 @@ case $1 in ;; start | stop) + if [ $# -lt 4 ] + then + echo "Not enough arguments" + usage + exit 1 + fi + while [ $# -gt 0 ]; do if [ $1 = "start" ]; then letter=S @@ -251,6 +296,31 @@ case $1 in makelinks ;; + enable | disable) + if [ $1 = "enable" ]; then + letter=S + elif [ $1 = "disable" ]; then + letter=K + else + usage + exit 1 + fi + shift + if [ $# -gt 0 ] + then + case $1 in + S|2|3|4|5) + renamelinks $letter $1 + ;; + *) + usage + exit 1 + ;; + esac + else + renamelinks $letter + fi + ;; *) usage exit 1 -- 2.7.4 -- ___ yocto mailing list yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/yocto