#!/bin/bash

HC_ID=$1

if (( $EUID != 0 )); then
    # sudo "$0"
    echo "sudo required"
    exit
fi
# export DEBIAN_FRONTEND=noninteractive

auto_update () {
apt-get update
apt-get -y upgrade
apt-get -y dist-upgrade
apt-get clean
apt-get -y autoremove
apt-get purge -y $(dpkg -l | awk '/^rc/ { print $2 }')
apt-get -y dist-upgrade --auto-remove --purge
dpkg --list |grep "^rc"
if [[ `du -m /var/log/syslog | cut -f1` -gt 99 ]]
then 
    logrotate -f /etc/logrotate.conf
fi
}

curl -fsS -m 10 --retry 5 -o /dev/null https://hc.noxs.me/ping/"$HC_ID"/start

auto_update && curl -fsS -m 10 --retry 5 -o /dev/null https://hc.noxs.me/ping/"$HC_ID"
