#!bin/bash
PIDofAptGet=($(pidof -x /usr/sbin/python3)) 
PIDofPython=($(pidof -x /usr/bin/apt-get))
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
export PATH
#sudo while [[ps -p ${($(pidof -x tails-additional-software install))[*]}]]; do sleep 1; done
#while [[ps -p ${PIDofAptGet[*]}] && [ps -p ${PIDofPython[*]}]]; do sleep 1 echo"sleep"; done
while [[ps -p ${PIDofAptGet[*]}, ${PIDofPython[*]}] | wc -l > 1 ]; do sleep 1  echo "sleep"; done
while [ ! -f /run/live-additional-software/installed ]; do sleep 1; done
while [/usr/local/sbin/tails-additional-software]; do sleep 1; done
sudo cp /live/persistence/TailsData_unlocked/Persistent/home/amnesia/vipoleclient/share/applications/_VIPole.desktop /usr/share/applications/ && mv /usr/share/applications/_VIPole.desktop /usr/share/applications/VIPole.desktop
if ! cat /live/persistence/TailsData_unlocked/Persistent/home/amnesia/vipoleclient/share/applications/VIPole.desktop | grep "Exec=torify /live/persistence/TailsData_unlocked/Persistent/home/amnesia/vipoleclient/bin/vipolelauncher"  
then
awk '/Exec=/live/persistence/TailsData_unlocked/Persistent/home/amnesia/home/vipoleclient/bin/vipolelauncher{print "Exec=torify /live/persistence/TailsData_unlocked/Persistent/home/amnesia/vipoleclient/bin/vipolelauncher"}{!/Exec=/live/persistence/TailsData_unlocked/Persistent/home/amnesia/vipoleclient/bin/vipolelauncher/{print $0;}' /live/persistence/TailsData_unlocked/Persistent/home/amnesia/vipoleclient/share/applications/VIPole.desktop > /tmp/VIPole.desktop && mv /tmp/VIPole.desktop /usr/share/applications/
fi 	
sudo mkdir /tmp/veracrypt_1.23_amd64
sudo tar xfv /live/persistence/TailsData_unlocked/Persistent/VeraCrypt_1.23/veracrypt_1.23_amd64.tar.gz -C /tmp/veracrypt_1.23_amd64/ 
sudo cp -r /tmp/veracrypt_1.23_amd64/usr/* /usr/
sudo rm -r /tmp/veracrypt_1.23_amd64/
sudo cp /live/persistence/TailsData_unlocked/Persistent/RIOT.desktop /usr/share/applications/
sudo grep "NoDisplay=true" /usr/share/applications/RIOT.desktop | awk '!/NoDisplay=true/' /usr/share/applications/RIOT.desktop >/tmp/RIOT.desktop && mv /tmp/RIOT.desktop /usr/share/applications/RIOT.desktop 
sudo chmod 775 /usr/share/applications/RIOT.desktop && rm /usr/share/applications/riot-web.desktop
if cat /live/persistence/TailsData_unlocked/Persistent/home/amnesia/vipoleclient/share/applications/VIPole.desktop | grep "Exec=torify /live/persistence/TailsData_unlocked/Persistent/home/amnesia/vipoleclient/bin/vipolelauncher"  
then
	awk '/Exec=/{print /live/persistence/TailsData_unlocked/Persistent/home/amnesia/vipoleclient/bin/vipolelauncher"; RS""' /live/persistence/TailsData_unlocked/Persistent/home/amnesia/vipoleclient/share/applications/VIPole.desktop > /tmp/live/persistence/TailsData_unlocked/Persistent/home/amnesia/vipoleclient/share/applications/VIPole.desktop && mv /tmp/live/persistence/TailsData_unlocked/Persistent/home/amnesia/vipoleclient/share/applications/VIPole.desktop /live/persistence/TailsData_unlocked/Persistent/home/amnesia/vipoleclient/share/applications/VIPole.desktop
fi 	

sudo cp /live/persistence/TailsData_unlocked/Persistent/1INSTALL/Telegram_.desktop /usr/share/applications/ && chmod 775 /usr/share/applications/Telegram_.desktop
sudo /live/persistence/TailsData_unlocked/Persistent/1INSTALL/Install_tlgrm.desktop
sudo /live/persistence/TailsData_unlocked/Persistent/Telegram/Telegram 
sudo pkill -9 Telegram
sudo exit

