summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorTomas Novotny <tomas@novotny.cz>2014-12-12 16:50:51 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-12-19 18:08:01 +0000
commitd5e0cc7b08e6960f17c65a9588b23022b22c0fcc (patch)
treebf791867e528f355c3dbd02dba96dafe20e31881 /meta
parent0932d84f265446fae5bdb587529f8510742e0c70 (diff)
downloadpoky-d5e0cc7b08e6960f17c65a9588b23022b22c0fcc.tar.gz
systemd-systemctl: add handling of template unit files
Template unit files (those with '@' in their names) are not handled with native version of systemctl. This is usually not a problem, as the native systemctl fails and systemctl command is executed during first boot. But some early boot template units may fail during first boot because opkg configure for first boot is pulled too late for them (although I encouter it only with some of my services, not with oe-core ones). Handling of template unit files is same as in original systemctl. Also DefaultInstance directive in template is respected. As with original systemctl, enabling of template without instance and DefaultInstance does nothing. (From OE-Core rev: 90904ef3bab182a46174f7bb60e83f0f22a3f209) Signed-off-by: Tomas Novotny <tomas@novotny.cz> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rwxr-xr-xmeta/recipes-core/systemd/systemd-systemctl/systemctl45
1 files changed, 37 insertions, 8 deletions
diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl
index b37f27abfb..2e632b00bc 100755
--- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
+++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
@@ -77,18 +77,31 @@ for service in $services; do
77 exit 0 77 exit 0
78 fi 78 fi
79 79
80 echo "Try to find location of $service..." 80 service_base_file=`echo $service | sed 's/\(@\).*\(\.[^.]\+\)/\1\2/'`
81 if [ -z `echo $service | sed '/@/p;d'` ]; then
82 echo "Try to find location of $service..."
83 service_template=false
84 else
85 echo "Try to find location of template $service_base_file of instance $service..."
86 service_template=true
87 if [ -z `echo $service | sed 's/^.\+@\(.*\)\.[^.]\+/\1/'` ]; then
88 instance_specified=false
89 else
90 instance_specified=true
91 fi
92 fi
93
81 # find service file 94 # find service file
82 for p in $ROOT/etc/systemd/system \ 95 for p in $ROOT/etc/systemd/system \
83 $ROOT/lib/systemd/system \ 96 $ROOT/lib/systemd/system \
84 $ROOT/usr/lib/systemd/system; do 97 $ROOT/usr/lib/systemd/system; do
85 if [ -e $p/$service ]; then 98 if [ -e $p/$service_base_file ]; then
86 service_file=$p/$service 99 service_file=$p/$service_base_file
87 service_file=${service_file##$ROOT} 100 service_file=${service_file##$ROOT}
88 fi 101 fi
89 done 102 done
90 if [ -z "$service_file" ]; then 103 if [ -z "$service_file" ]; then
91 echo "'$service' couldn't be found; exiting with error" 104 echo "'$service_base_file' couldn't be found; exiting with error"
92 exit 1 105 exit 1
93 fi 106 fi
94 echo "Found $service in $service_file" 107 echo "Found $service in $service_file"
@@ -115,13 +128,29 @@ for service in $services; do
115 for r in $wanted_by; do 128 for r in $wanted_by; do
116 echo "WantedBy=$r found in $service" 129 echo "WantedBy=$r found in $service"
117 if [ "$action" = "enable" ]; then 130 if [ "$action" = "enable" ]; then
131 enable_service=$service
132 if [ "$service_template" = true -a "$instance_specified" = false ]; then
133 default_instance=$(sed '/^DefaultInstance[[:space:]]*=/s,[^=]*=,,p;d' "$ROOT/$service_file")
134 if [ -z $default_instance ]; then
135 echo "Template unit without instance or DefaultInstance directive, nothing to enable"
136 continue
137 else
138 echo "Found DefaultInstance $default_instance, enabling it"
139 enable_service=$(echo $service | sed "s/@/@$default_instance/")
140 fi
141 fi
118 mkdir -p $ROOT/etc/systemd/system/$r.wants 142 mkdir -p $ROOT/etc/systemd/system/$r.wants
119 ln -s $service_file $ROOT/etc/systemd/system/$r.wants 143 ln -s $service_file $ROOT/etc/systemd/system/$r.wants/$enable_service
120 echo "Enabled $service for $wanted_by." 144 echo "Enabled $enable_service for $wanted_by."
121 else 145 else
122 rm -f $ROOT/etc/systemd/system/$r.wants/$service 146 if [ "$service_template" = true -a "$instance_specified" = false ]; then
147 disable_service="$ROOT/etc/systemd/system/$r.wants/`echo $service | sed 's/@/@*/'`"
148 else
149 disable_service="$ROOT/etc/systemd/system/$r.wants/$service"
150 fi
151 rm -f $disable_service
123 rmdir --ignore-fail-on-non-empty -p $ROOT/etc/systemd/system/$r.wants 152 rmdir --ignore-fail-on-non-empty -p $ROOT/etc/systemd/system/$r.wants
124 echo "Disabled $service for $wanted_by." 153 echo "Disabled ${disable_service##$ROOT/etc/systemd/system/$r.wants/} for $wanted_by."
125 fi 154 fi
126 done 155 done
127 156