0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

softetherのunitファイル作成スクリプト

Posted at

備忘録。
たまに作るとなんだっけ?となるのでここに自作スクリプト書いておく。

#!/bin/bash

unitname=softether-vpn.service
unitfile=/etc/systemd/system/$unitname
tempfile=$(mktemp)
ifname=$(ip -o link show | grep ^2 | sed -e "s/://g" | awk '{ print $2 }')

cat << EOS >> $tempfile
[Unit]
Description=Softether VPN Server Service
After=network.target

[Service]
Type=forking
User=root
ExecStart=/usr/local/vpnserver/vpnserver start
ExecStop=/usr/local/vpnserver/vpnserver stop
Restart=on-abort
WorkingDirectory=/usr/local/vpnserver
ExecStartPre=/sbin/ip link set dev $ifname promisc on

[Install]
WantedBy=multi-user.target
EOS

cp -pvf "$tempfile" "$unitfile"
[ -f "$tempfile" ] && rm -f "$tempfile"

systemctl daemon-reload
systemctl enable $unitname
systemctl start $unitname
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?