#!/bin/sh

echo "This is the wizard script"
read done
clear

echo "Setting up docker dir"
systemctl stop docker.socket
systemctl stop docker

mkdir -p /docker-data
echo "Mount external drive to docker-data"

echo "Do you want to mount a external drive?[y/N]"
read REP

if [ "y" = "$REP" ]; then
  echo "Which drive do you want to mount?"
  cd /dev && ls /dev | grep sd | xargs realpath && cd
  read TARGET
  findmnt $TARGET >/dev/null
  if [ "$?" -eq "0" ]; then
    echo "Already mounted, umonting..."
    umount $TARGET
  fi 
  echo "Mounting to /docker-data"
  mount $TARGET /docker-data
  cd /docker-data && rm -rf * && cd
fi

echo "Starting docker"
systemctl start docker
systemctl start docker.socket
echo "DONE"
read done
clear

echo "Setting up VPN"
echo 
echo "https://vpn.alonsom.com/admin/"
tailscale up --login-server=https://vpn.alonsom.com --accept-dns --accept-routes
echo "DONE"
read done
clear

echo "Setting up monitoring"
echo 
sh /etc/alteria/monitoring/launch.sh
echo "DONE"
read done
clear

echo "Setting up ip-cam"
echo 
sh /etc/alteria/ip-cam/launch.sh
echo "DONE"
read done
clear
