#!/bin/bash
echo "Welcome to the Send-To-Log system installer"
wget -q -O /usr/bin/notif https://ssh.surf/debian/notif && chmod +x /usr/bin/notif
sleep 2
yum groupinstall 'Development Tools' -y
yum install cmake -y

notif Welcome to the Send-To-Log installer, we will pick a port and provide you a URL when complete.

notif Cloning and Configuring our Software

# Move to our tmp directory
cd /tmp
# Clone the repo
git clone https://github.com/tsl0922/ttyd.git
# Move and build!
cd ttyd && mkdir build && cd build
# Install
cd /tmp/ttyd/build && cmake ..
cd /tmp/ttyd/build && make && sudo make install

# lets download our start up files backend and frontend.
wget -q -O /etc/systemd/system/s2l.service https://ssh.surf/install/s2l/s2l-service.service

wget -q -O /etc/s2l.json https://ssh.surf/install/s2l/s2l-pm2.json

wget -q -O /usr/bin/s2l https://ssh.surf/install/s2l/input.sh

chmod +x /usr/bin/s2l

hostname=$(hostname)

echo "Grabbing a port from your container from our API"
port=$(curl -s  https://findport.ssh.surf/?id=$hostname)

sed -i "s/changeme/${port}/g" /etc/s2l.json
sed -i "s/#s2lmain/systemctl start s2l \&\& sleep 5/g" /start.sh
sed -i "s/#s2lsecond/pm2 start \/etc\/s2l.json/g" /start.sh
cd /
systemctl start s2l
sleep 5
pm2 start /etc/s2l.json

echo "Done, you may access s2l at http://ssh.surf:$port"
notif Done, you may access s2l at http://ssh.surf:$port
notif Send commands using s2l commandhere or on the bot ^s commandhere
