Re: Problems running on startup a service created in a postinstall script in 12.3
Robert Klein <[email protected]>
| Newsgroups | gmane.linux.suse.autoinstall |
|---|---|
| Message-ID | <[email protected]> |
Hi,
is here a reason for using an init script outside of autoyast?
I'm using a lot of autoyast post-scripts and init-scripts. Network /is/
an issue, both in post-scripts and init-scripts:
1. Network access (dhcp, autofs) not (yet) available in post-scripts.
2. Dhcp answer arriving late in init-scripts.
3. Fixing IP address with an init-script works, but network isn't really
available for the next script. Funny though, it /is/ available in the
same script.
So I currently put most of the configuration in one big autoyast init
script beginning with:
#+begin_example sh
#!/bin/sh
##
## 00 - set static IP Address for active interface
##
# get active interface
act_iface=$(/sbin/ip link | grep '[1-9]*: eth' | grep 'state UP' | awk
'{print $2}' | sed 's/://')
# get ip settings
ip_settings=$(ip addr show ${act_iface} | grep '^ *inet ' | awk '{print
$2}')
# extract ip address
ip_addr=$(echo ${ip_settings} | sed 's/\/[0-9]*//')
# extract network prefix (mask)
prefix=$(echo ${ip_settings} | sed 's/[0-9.]*\///')
# set static address
yast2 lan edit id=0 ip=${ip_addr} prefix=${prefix}
#+end_example
(this isn't perfect, but works if eth0 is the active network interface)
After setting the IP address, I do the rest of our configuration, e.g.
allow use of sshfs, deploy modules, set up ofed, run updates.
Now, there is another catch: I set final_reboot to true in autoyast.
The final reboot happens in the zzz_reboot script, the last of the
autoyast init-scripts. however, if the whole shebang runs over about 5
minutes, systemd kills the main autoyast init script. Your current
init-script finishes, but none of the others get started, including
zzz_reboot. My script currently takes about 20 minutes (because of
doing updates), so my last commands in it are (right out of zzz_reboot):
chkconfig autoyast off
shutdown -r now
I think this can help you with your setup.
BTW, openSUSE 12.3 should still be able to run old style (system v init)
init scripts.
Note: I still use 12.2.
Best regards
Robert
On 04/15/2013 10:57 AM, Rainer Krienke wrote:
> Hello,
>
> to automatically install a openSuSE 12.3 desktop client that fits into
> our network environment I need to change several configs uopn
> installtion so little manual postinstallation is needed afterwards. I do
> this using an autoyast installation that includes a postinstall script.
> This used to work fine until systemd came up.
>
> In openSuSE 12.3 I create a service file
> /lib/systemd/system/lfinalinstall that looks like this:
> ------------------
> [Unit]
> Description=lfinalinstall install script
> After=apparmor.service local-fs.target network.service
> Before=xdm.service
>
> [Service]
> Type=oneshot
> Environment=SYSTEMD_NO_WRAP=1 TERM=linux
> ExecStart=$LSCRIPT
> RemainAfterExit=yes
> TimeoutSec=0
> StandardInput=tty
>
> [Install]
> WantedBy=default.target
> -----------------
>
> Next I run "/bin/systemctl enable lfinalinstall" and finally I run
> "systemctl daemon-reload"
>
> After the postinstall scripts of autoyast have been executed my script
> lfinalinstall is actually beeing started. The problem is that it
> depends on a running network, but the interface eth0 is still
> unconfigured (no dhcpcd is running for it yet, no ip assigned) at this
> time and so my script cannot do the job its supposed to do and fails.
> After a manual reboot thisngs work.
>
> Does anyone have an idea what I have to do to have the finalinstall
> service started when network is available? The dependency on
> network.service seems not to work for me.
>
> Thanks
> Rainer Krineke
>
--
To unsubscribe, e-mail: [email protected]
To contact the owner, e-mail: [email protected]