Skip to content

Instantly share code, notes, and snippets.

@ZuZuD
Created April 2, 2018 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZuZuD/d344de0004d7fa40034149ed4ea93860 to your computer and use it in GitHub Desktop.
Save ZuZuD/d344de0004d7fa40034149ed4ea93860 to your computer and use it in GitHub Desktop.
Kodi bash alias
kodi_ip=192.168.0.100
function cpkodi {
scp $@ root@$kodi_ip:/storage/tvshows
}
function lskodi {
ssh root@$kodi_ip ls -ltrh /storage/tvshows
}
function rmkodi {
ssh root@$kodi_ip "cd /storage/tvshows && rm $@"
echo $?
lskodi
}
function vpnkodi {
vpn=$(ssh root@$kodi_ip "ps |grep 'openvpn --config'|grep -v grep")
len_vpn=${#vpn}
echo -e 'Would you.. :\n 1) Connect to VPN Paris\n 2) List all VPN\n 3) Kill all VPN\n'
read choice
case $choice in
1)
if [ $len_vpn -gt 0 ]; then
location=$(echo $vpn |awk '{print $6}'| sed 's/.ovpn//')
echo 'VPN is connected to' $location
echo -e 'Current open VPN details:\n'$vpn
else
echo 'VPN not established...establishing connection...'
ssh root@$kodi_ip "cd ~/OpenVPN;openvpn --config Paris2.ovpn > /dev/null & echo done"
fi
;;
2)
if [ $len_vpn -gt 0 ]; then
echo -e 'Current open VPN details:'
ssh root@$kodi_ip "ps |grep 'openvpn --config'|grep -v grep"
else
echo 'No VPN to list'
fi
;;
3)
if [ $len_vpn -gt 0 ]; then
echo -e 'Following VPN will be killed:'
ssh root@$kodi_ip "ps |grep 'openvpn --config'|grep -v grep"
ssh root@$kodi_ip "killall openvpn"
else
echo 'No VPN to kill'
fi
;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment