#!/bin/bash

#sudo apt remove anydesk --yes
killall anydesk
rm /etc/anydesk -rf
#rm /home/user/.anydesk/service.conf
rm /home/user/.anydesk -rf
rm /root/.anydesk -rf

if [ ! -f anydesk.deb ]; then
	ANY_DOWNLOAD_URL=http://rouletteupdates.4knh.com/anydesk.deb
	echo ""
	echo "INFO: anydesk.deb is missing. Trying to download ayndesk.deb installation package from $ANY_DOWNLOAD_URL"
	wget $ANY_DOWNLOAD_URL ./anydesk.deb
else
	echo ""
	echo "WARN: anydesk.deb found on disk. Install will continue using ./anydesk.deb."
	echo "INFO: Remove ./anydesk.deb if you want to re-download it again from the predefined URL."
	echo ""
fi
if [ ! -f anydesk.deb ]; then
	echo "can not download ayndesk.deb installation package. Aborting..."
	exit -1
fi

sudo dpkg -i anydesk.deb
apt --fix-broken install
sudo -u user anydesk --service

sleep 3
sudo su -c 'echo givelogin7 | anydesk --set-password'
sleep 1
