2018-08-06 01:56:44 +00:00
|
|
|
#!/hint/bash
|
|
|
|
|
2018-08-06 04:02:37 +00:00
|
|
|
load_module "$(dirname -- "${BASH_SOURCE[0]}")/testuser.sh"
|
2018-08-06 01:56:44 +00:00
|
|
|
|
|
|
|
post_install+=(10:systemd-osi-run:post_install)
|
|
|
|
systemd-osi-run:post_install() {
|
|
|
|
local arg_mountpoint=$1
|
|
|
|
|
|
|
|
cat <<-'EOT' > "${arg_mountpoint}/etc/systemd/system/osi-run.target"
|
|
|
|
[Unit]
|
|
|
|
Description=osi-run target
|
|
|
|
Requires=multi-user.target
|
|
|
|
After=multi-user.target
|
|
|
|
Conflicts=rescue.target
|
|
|
|
AllowIsolate=yes
|
|
|
|
EOT
|
2018-08-06 04:02:37 +00:00
|
|
|
ln -sT osi-run.target "${arg_mountpoint}/etc/systemd/system/default.target"
|
2018-08-06 01:56:44 +00:00
|
|
|
|
|
|
|
cat <<-'EOT' > "${arg_mountpoint}/etc/systemd/system/osi-run.service"
|
|
|
|
[Unit]
|
|
|
|
Description=osi-run service
|
2018-08-06 04:02:37 +00:00
|
|
|
Wants=network-online.target
|
|
|
|
After=network-online.target
|
2018-08-09 19:21:56 +00:00
|
|
|
ConditionPathExists=/etc/osi-run
|
2018-08-06 01:56:44 +00:00
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
2018-08-06 04:02:37 +00:00
|
|
|
StandardOutput=journal+console
|
2018-08-12 21:56:29 +00:00
|
|
|
ExecStart=/bin/bash -c '{ su testuser -c /etc/osi-run 2>&1; echo $? > /var/log/osi-run.status; } | tee /var/log/osi-run.out; systemctl poweroff --no-block'
|
2018-08-06 01:56:44 +00:00
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=osi-run.target
|
|
|
|
EOT
|
|
|
|
systemctl --root="$arg_mountpoint" enable osi-run.service
|
|
|
|
}
|