Fix: Update IP before start to make the start successful

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-06-21 10:04:56 +02:00
parent 77b1d27c7f
commit 296de656c6
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5
2 changed files with 15 additions and 13 deletions

View file

@ -1,5 +1,5 @@
pkgname=he-tunnel pkgname=he-tunnel
pkgver=0.1.0 pkgver=0.1.1
pkgrel=1 pkgrel=1
pkgdesc="Tunnel setup script and service" pkgdesc="Tunnel setup script and service"
arch=(any) arch=(any)
@ -11,11 +11,9 @@ source=(
he-tunnel he-tunnel
he-tunnel.service he-tunnel.service
) )
sha512sums=( sha512sums=('49b4970ca50bd6858111edaa756f31b860e02cbbe336691b28f69dd0cdd74b818d43c4a16a3c272834c4f056bcbb65eb78bfbc3bdac236684f1311918a8114f6'
'49b4970ca50bd6858111edaa756f31b860e02cbbe336691b28f69dd0cdd74b818d43c4a16a3c272834c4f056bcbb65eb78bfbc3bdac236684f1311918a8114f6' '731da391fac056b108e7db0191fb227785d46616866f08111a028914df3faef23433dd4dc881efad7ccc9beb0d04fdbca2c73fae70932213661c6baf735cf1af'
'78e3c2fbedba6b106eb682d0e493a7169787fba4c4b03f3d9e6fe32d14e25348cc5bb6c3cf95da7f551802b25f819c524daeea9e9f696fe3256d9b38585c75b8' '11073404bc2f62ea0f104e03858777793079edad657571c9ab8893a50acfbbe64648d126d8625592cef464f25b9304bd04e2d381f630e320a01cccd61b3c039b')
'11073404bc2f62ea0f104e03858777793079edad657571c9ab8893a50acfbbe64648d126d8625592cef464f25b9304bd04e2d381f630e320a01cccd61b3c039b'
)
package() { package() {
install -Dm 0600 config.default "${pkgdir}/etc/default/he-tunnel" install -Dm 0600 config.default "${pkgdir}/etc/default/he-tunnel"

View file

@ -14,8 +14,18 @@ function log() {
source ${DEFAULT_CFG} source ${DEFAULT_CFG}
function update_ip() {
log "Updating remote IP with tunnel broker..."
curl -4 -sSf \
-o /dev/null \
"https://${UPDATE_USER}:${UPDATE_KEY}@ipv4.tunnelbroker.net/nic/update?hostname=${TUNNEL_ID}"
log "IP updated."
}
case $1 in case $1 in
start) start)
update_ip
log "Configuring tunnel interface..." log "Configuring tunnel interface..."
/usr/bin/ip tunnel add he-ipv6 mode sit remote ${TUNNEL_REMOTE} local ${TUNNEL_LOCAL} ttl 255 /usr/bin/ip tunnel add he-ipv6 mode sit remote ${TUNNEL_REMOTE} local ${TUNNEL_LOCAL} ttl 255
/usr/bin/ip link set he-ipv6 up mtu 1480 /usr/bin/ip link set he-ipv6 up mtu 1480
@ -32,11 +42,5 @@ stop)
log "Tunnel interface removed." log "Tunnel interface removed."
;; ;;
update-ip) update-ip) update_ip ;;
log "Updating remote IP with tunnel broker..."
curl -4 -sSf \
-o /dev/null \
"https://${UPDATE_USER}:${UPDATE_KEY}@ipv4.tunnelbroker.net/nic/update?hostname=${TUNNEL_ID}"
log "IP updated."
;;
esac esac