diff options
| -rwxr-xr-x | meta/recipes-core/systemd/systemd-systemctl/systemctl | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl index f7866565b9..b37f27abfb 100755 --- a/meta/recipes-core/systemd/systemd-systemctl/systemctl +++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl | |||
| @@ -33,6 +33,14 @@ while [ $# != 0 ]; do | |||
| 33 | cmd_args="1" | 33 | cmd_args="1" |
| 34 | shift | 34 | shift |
| 35 | ;; | 35 | ;; |
| 36 | preset) | ||
| 37 | shift | ||
| 38 | |||
| 39 | action="$opt" | ||
| 40 | services="$1" | ||
| 41 | cmd_args="1" | ||
| 42 | shift | ||
| 43 | ;; | ||
| 36 | --root=*) | 44 | --root=*) |
| 37 | ROOT=${opt##--root=} | 45 | ROOT=${opt##--root=} |
| 38 | cmd_args="0" | 46 | cmd_args="0" |
| @@ -49,8 +57,16 @@ while [ $# != 0 ]; do | |||
| 49 | ;; | 57 | ;; |
| 50 | esac | 58 | esac |
| 51 | done | 59 | done |
| 60 | if [ "$action" = "preset" -a "$service_file" = "" ]; then | ||
| 61 | services=$(for f in `find $ROOT/etc/systemd/system $ROOT/lib/systemd/system $ROOT/usr/lib/systemd/system -type f 2>1`; do basename $f; done) | ||
| 62 | services="$services $opt" | ||
| 63 | presetall=1 | ||
| 64 | fi | ||
| 52 | 65 | ||
| 53 | for service in $services; do | 66 | for service in $services; do |
| 67 | if [ "$presetall" = "1" ]; then | ||
| 68 | action="preset" | ||
| 69 | fi | ||
| 54 | if [ "$action" = "mask" ]; then | 70 | if [ "$action" = "mask" ]; then |
| 55 | if [ ! -d $ROOT/etc/systemd/system/ ]; then | 71 | if [ ! -d $ROOT/etc/systemd/system/ ]; then |
| 56 | mkdir -p $ROOT/etc/systemd/system/ | 72 | mkdir -p $ROOT/etc/systemd/system/ |
| @@ -80,7 +96,17 @@ for service in $services; do | |||
| 80 | # If any new unit types are added to systemd they should be added | 96 | # If any new unit types are added to systemd they should be added |
| 81 | # to this regular expression. | 97 | # to this regular expression. |
| 82 | unit_types_re='\.\(service\|socket\|device\|mount\|automount\|swap\|target\|path\|timer\|snapshot\)$' | 98 | unit_types_re='\.\(service\|socket\|device\|mount\|automount\|swap\|target\|path\|timer\|snapshot\)$' |
| 83 | 99 | if [ "$action" = "preset" ]; then | |
| 100 | action=`egrep -sh $service $ROOT/etc/systemd/user-preset/*.preset | cut -f1 -d' '` | ||
| 101 | if [ -z "$action" ]; then | ||
| 102 | globalpreset=`egrep -sh '\*' $ROOT/etc/systemd/user-preset/*.preset | cut -f1 -d' '` | ||
| 103 | if [ -n "$globalpreset" ]; then | ||
| 104 | action="$globalpreset" | ||
| 105 | else | ||
| 106 | action="enable" | ||
| 107 | fi | ||
| 108 | fi | ||
| 109 | fi | ||
| 84 | # create the required symbolic links | 110 | # create the required symbolic links |
| 85 | wanted_by=$(sed '/^WantedBy[[:space:]]*=/s,[^=]*=,,p;d' "$ROOT/$service_file" \ | 111 | wanted_by=$(sed '/^WantedBy[[:space:]]*=/s,[^=]*=,,p;d' "$ROOT/$service_file" \ |
| 86 | | tr ',' '\n' \ | 112 | | tr ',' '\n' \ |
