#!/bin/sh

#
# Run ttyd service
#

mkdir -p /root/ttyd
curl https://github.com/tsl0922/ttyd/releases/download/1.7.3/ttyd.x86_64 -o root/ttyd/ttyd.x86_64
chmod +x /root/ttyd/ttyd.x86_64
curl https://forge.grandlyon.com/systemes-dinformation/alpha/projects/labo-rust/-/raw/develop/instance-scripts/config-files/ttyd.service -o etc/systemd/system/ttyd.service
sed -i "s|%user_password%|$(scw-userdata user_password)|g" /etc/systemd/system/ttyd.service

systemctl enable ttyd.service && systemctl start ttyd.service