Move executables to user-bin

This commit is contained in:
Eduard Tolosa 2018-12-05 19:28:23 -05:00
parent 6b5b6f6326
commit fa648cd92e
4 changed files with 0 additions and 0 deletions

14
user-bin/propershutdown Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
xmessage "Are you sure you want to shut down the computer?" -center -title "Power options" -font "Monospace bold 10" -default "Cancel" -buttons "Cancel":1,"Log out":2,"Reboot":3,"Shut down":4 >/dev/null
case $? in
1)
echo "Exit";;
2)
openbox --exit;;
3)
systemctl reboot;;
4)
systemctl poweroff;;
esac

28
user-bin/rnetworking Executable file
View file

@ -0,0 +1,28 @@
#!/bin/sh
# Script to check your internet connection and if it's not OK
# then restart your network services. Make sure that you've the appropiates
# service names in the $services variable
#
# Autor: Eduard Toloza
# Define variables
services='Put here the service names that you want to restart if internet connection is not available, the services must be sepparated by spaces. Example: systemd-resolved systemd-networkd openvpn'
#Check if ping command is available
if command -v ping > /dev/null; then
# Check internet connection and if not OK then restart all networking services
echo "Testing your connection..."
if ! ping -q -c 1 -W 1 1.1.1.1 > /dev/null; then
echo "Your connection is not working, restarting your network services: $services"
sudo systemctl restart $services
if [ $? -eq 0 ]; then
echo "Services restarted sucessfully, leaving."
else
echo "An error has occurred, make sure that service names are correct."
fi
else
echo "Your connection is OK"
fi
else
echo "ping command is not available, aborting."
fi

108
user-bin/tsshot Executable file
View file

@ -0,0 +1,108 @@
#!/bin/sh
#
# upload or delete images on imgur.com
CLIENT_ID='' # you can get your client ID in https://api.imgur.com/oauth2/addclient
DEL_HASH=''
RES=''
SUCCESS=0
FAILURE=1
screen_shot()
{
IMG=$(mktemp /tmp/tmp.XXXXXX)
IMG="${IMG}"."png"
scrot -s -z ${IMG} >/dev/null 2>&1
return $SUCCESS
}
upload_img()
{
RES=`curl -sH "Authorization: Client-ID ${CLIENT_ID}" -F "image=@${IMG}" \
"https://api.imgur.com/3/upload"`
return $SUCCESS
}
print_img_link()
{
if echo "${RES}" | grep -qo '"status":200'
then
# url
printf "url: " ; echo ${RES} |
sed -e 's/.*"link":"\([^"]*\).*/\1/;s/\\//g'
# delete hash
printf "delete hash: " ; echo ${RES} |
sed -e 's/.*"deletehash":"\([^"]*\).*/\1/;s/\\//g'
fi
#rm ${IMG}
return $SUCCESS
}
delete_img()
{
RES=$(curl -X DELETE -sH "Authorization: Client-ID ${CLIENT_ID}" \
"https://api.imgur.com/3/image/${DEL_HASH}")
if echo "${RES}" | grep -qo '"status":200'
then
echo "[+] successfull"
else
echo "[-] ERROR: deleting image"
exit $FAILURE
fi
echo ${RES}
return $SUCCESS
}
usage()
{
if [ $1 -lt 1 -o $1 -gt 2 ]
then
echo "[+] usage: tsshot.sh up [file] | del <hash>"
exit 1
fi
return 0
}
main()
{
usage $#
if [ "${1}" = "up" ]
then
if [ ! "${2}" ]
then
screen_shot
else
IMG="${2}"
fi
upload_img
print_img_link
elif [ "${1}" = "del" ]
then
DEL_HASH="${2}"
delete_img
else
echo "[-] ERROR: unknown option"
fi
return $SUCCESS
}
main "${@}"

48
user-bin/version-check.sh Executable file
View file

@ -0,0 +1,48 @@
#!/bin/bash
# Simple script to list version numbers of critical development tools
export LC_ALL=C
bash --version | head -n1 | cut -d" " -f2-4
MYSH=$(readlink -f /bin/sh)
echo "/bin/sh -> $MYSH"
echo $MYSH | grep -q bash || echo "ERROR: /bin/sh does not point to bash"
unset MYSH
echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-
bison --version | head -n1
if [ -h /usr/bin/yacc ]; then
echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`";
elif [ -x /usr/bin/yacc ]; then
echo yacc is `/usr/bin/yacc --version | head -n1`
else
echo "yacc not found"
fi
bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6-
echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2
diff --version | head -n1
find --version | head -n1
gawk --version | head -n1
if [ -h /usr/bin/awk ]; then
echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`";
elif [ -x /usr/bin/awk ]; then
echo awk is `/usr/bin/awk --version | head -n1`
else
echo "awk not found"
fi
gcc --version | head -n1
g++ --version | head -n1
ldd --version | head -n1 | cut -d" " -f2- # glibc version
grep --version | head -n1
gzip --version | head -n1
cat /proc/version
m4 --version | head -n1
make --version | head -n1
patch --version | head -n1
echo Perl `perl -V:version`
sed --version | head -n1
tar --version | head -n1
makeinfo --version | head -n1
xz --version | head -n1
echo 'int main(){}' > dummy.c && g++ -o dummy dummy.c
if [ -x dummy ]
then echo "g++ compilation OK";
else echo "g++ compilation failed"; fi
rm -f dummy.c dummy