Hello to everyone.
I'm using Debian 12. I'm configuring a little Debian 12 vm with qemu that I will use to forward the cloudflare connection to FreeBD.
What I want to do is to run the script below as soon as root has logged in.
I've configured the automatic login of root adding to this service file :
nano /etc/systemd/system/getty.target.wants/getty@tty1.service
this line :
ExecStart=/sbin/agetty -o '-p -f -- \\u" --noclear --autologin root %I $TERM
Now,what I want to do is that the script below is ran as soon root is able to logged in automatically :
/usr/bin/warp
warp-cli disconnect
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -A POSTROUTING -t nat -s 192.168.1.5 -j MASQUERADE
warp-cli connect
echo Connected to Cloudflare Warp...
echo OLD IP is : $OLD_IP,NEW IP is : $NEW_IP
[Forgot to say that I switched boot target to text with this command :
sudo systemctl set-default multi-user.target]
What I tried right now has been to create a respawn service with systemd.
I created a file in /etc/systemd/system/
i.e. warp.service
[Unit]
Desription=warp with systemd, respawn
After=pre-network.target
[Service]
ExecStart=/usr/bin/warp
Restart=always
[Install]
WantedBy=multi-user.target
and I've activated it :
systemctl enable warp.service
rebooted and started it manually :
systemctl daemon-reload
systemctl start warp.service
It does not work and anyway it does not seem to be what I want...
I want that the warp script is run everytime root is logged in,not more,not less.
I suspect that the solution is easier than what I'm trying to do...
--
Mario.