#!/bin/bash
#set -x -e

cat > /home/ubuntu/autostart.sh <<EOF
#!/bin/bash
mount -a
sudo systemctl enable --now solana
EOF

chmod +x /home/ubuntu/autostart.sh

cat > /lib/systemd/system/autostart.service <<EOF
[Unit]
Description=Autostart Service
After=multi-user.target
[Service]
Type=idle
ExecStart=/home/ubuntu/autostart.sh
[Install]
WantedBy=multi-user.target
EOF

sudo chmod 644 /lib/systemd/system/autostart.service

sudo systemctl daemon-reload
sudo systemctl enable autostart.service

echo "$(wget -q -4 -O- http://icanhazip.com)"
