I have a script which is supposed to be executed on boot when the network connection is established (local network would be sufficient). It is the shell version of linphone.

This is my current unit content:

Description=Register Linphone as Client at SIP Server
After=network-online.target network.target multi-user.target

ExecStart=/usr/bin/bash /usr/local/bin/service_network/linphonec_init.sh


This is the script linphonec_init.sh which is supposed to be executed by the unit:

#! /bin/bash

linphonecsh exit
linphonecsh init
sleep 1
linphonecsh register --host --username 9910 --password 123456
sleep 1
result=$(linphonecsh status register)

if [[ $result == *"identity=sip"* ]]; then
  echo "Registration successful"
  exit 0
  echo "Not registered"
  exit 1

First of all: Are both scripts correct? I can't test it right now, but in an earlier version I had no network connection after booting (with Ethernet). My expectation is that this service runs once after the network is only. If it exits successfully it is not started again, otherwise it will be restarted after 5 seconds. Right?

How could I now add a routine which repeatedly checks if the network is available and if not restarts the network interface?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.