added lots of functions and some more scripts in bin
This commit is contained in:
parent
d691dd5497
commit
6401c1ea67
7 changed files with 153 additions and 0 deletions
|
@ -42,3 +42,47 @@ check_open_resolver()
|
|||
{
|
||||
nmap -sU -p 53 -sV -P0 --script "dns-recursion" "$1"
|
||||
}
|
||||
|
||||
fix_spaces()
|
||||
|
||||
{
|
||||
for i in $1/*
|
||||
do mv -v "$i" "$(echo $i | sed 's/ /_/g')"
|
||||
done
|
||||
}
|
||||
|
||||
sqrt()
|
||||
|
||||
{
|
||||
[ $# -ne 1 ] && {
|
||||
echo 'Usage: sqrt number'
|
||||
exit 1
|
||||
} || {
|
||||
echo -e "sqrt($1)\nquit\n" | bc -q -i | head -2 | tail -1
|
||||
}
|
||||
|
||||
cx()
|
||||
|
||||
{
|
||||
chmod +x $1
|
||||
}
|
||||
|
||||
ssl()
|
||||
|
||||
{
|
||||
|
||||
openssl s_client -connect $1:443
|
||||
}
|
||||
|
||||
mem_usage()
|
||||
|
||||
{
|
||||
ps aux |grep -v USER|awk '{ cpu[$1]+=$3; rss[$1]+=$6; sum+=$6} END { for (user in cpu) printf("%-11s Memory: %9.1f MiB CPU%%: %5.1f\n", user, rss[user]/1024, cpu[user]); } END {printf("Total Memory: %15.1f MiB", sum/1024);}'|sort -n -k3;echo;free -m|egrep -v 'Mem|Swap'
|
||||
}
|
||||
|
||||
swap_sum()
|
||||
|
||||
{
|
||||
# this will grab swap usage and each program using swap and total it.
|
||||
for dir in $(find /proc/ -maxdepth 1 -type d | egrep "^/proc/[0-9]") ; do pid=$(echo $dir | cut -d / -f 3);prog=$(ps -p $pid -o comm --no-headers|awk '{print $1}'); for swap in $(grep Swap $dir/smaps 2>/dev/null| awk '{print $2}');do let sum=$sum+$swap; done; echo "$prog $sum "|grep -vw 0;sum=0;done|awk '{ swap[$1]+=$2; sum+=$2} END { for (prog in swap) printf("%-15s Swap: %10.1f MiB\n", prog, swap[prog]/1024); } END {printf("Total Swap: %20.1f MiB", sum/1024);}'|sort -n -k3
|
||||
}
|
||||
|
|
29
bin/celsius_to_farenheit.sh
Executable file
29
bin/celsius_to_farenheit.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
# shell script to convert celsius temp to farenheit
|
||||
# taken from: https://www.linuxquestions.org/questions/ubuntu-63/shell-script-to-convert-celsius-to-fahrenheit-929261/
|
||||
|
||||
echo "*** Converting between the different temperature scales ***"
|
||||
echo "1. Convert Celsius temperature into Fahrenheit"
|
||||
echo "2. Convert Fahrenheit temperatures into Celsius"
|
||||
echo -n "Select your choice (1-2) : "
|
||||
read choice
|
||||
|
||||
if [ $choice -eq 1 ]
|
||||
then
|
||||
echo -n "Enter temperature (C) : "
|
||||
read tc
|
||||
# formula Tf=(9/5)*Tc+32
|
||||
tf=$(echo "scale=2;((9/5) * $tc) + 32" |bc)
|
||||
echo "$tc C = $tf F"
|
||||
|
||||
elif [ $choice -eq 2 ]
|
||||
then
|
||||
echo -n "Enter temperature (F) : "
|
||||
read tf
|
||||
# formula Tc=(5/9)*(Tf-32)
|
||||
tc=$(echo "scale=2;(5/9)*($tf-32)"|bc)
|
||||
echo "$tf = $tc"
|
||||
else
|
||||
echo "Please select 1 or 2 only"
|
||||
exit 1
|
||||
fi
|
10
bin/greetings.sh
Executable file
10
bin/greetings.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
#program to print a greeting
|
||||
|
||||
hour=$(date +%H)
|
||||
|
||||
case "$hour" in
|
||||
0? | 1[01] ) echo "Good morning $USER";;
|
||||
1[2-7] ) echo "Good afternoon $USER";;
|
||||
* ) echo "Good evening $USER";;
|
||||
esac
|
18
bin/install_ts.sh
Executable file
18
bin/install_ts.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
# this will download and install teamspeak client on 64 bit linux machine.
|
||||
# run as the root user
|
||||
|
||||
# variables for installation files
|
||||
# update this as needed. i dont keep it up to date. you can find the latest files on teamspeaks website
|
||||
|
||||
download_url="http://teamspeak.gameserver.gamed.de/ts3/releases/3.0.18.2/TeamSpeak3-Client-linux_amd64-3.0.18.2.run"
|
||||
filename="TeamSpeak3-Client-linux_amd64-3.0.18.2.run"
|
||||
|
||||
mkdir /opt/teamspeak
|
||||
cd /opt/teamspeak
|
||||
wget $download_url
|
||||
chmod +x $filename
|
||||
ln -sv /opt/teamspeak/ts3client_runscript.sh /usr/bin/teamspeak
|
||||
echo 'installation finished'
|
||||
echo 'teamspeak client is installed in /opt/teamspeak'
|
||||
echo 'the binary runscript is symlinked to /usr/bin/teamspeak'
|
19
bin/php_function_check.sh
Executable file
19
bin/php_function_check.sh
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
# check if a php function exists on a system
|
||||
# output results to a file
|
||||
|
||||
usage() {
|
||||
echo "Usage: $(basename $0) function_name > filename.php"
|
||||
}
|
||||
|
||||
if [[ $1 = "--help" ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $# != 1 ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "<?php echo function_exists('"$1"')?'yes':'no'; ?>"
|
23
bin/todolist.sh
Executable file
23
bin/todolist.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
# generates todolist
|
||||
|
||||
arg="$1"
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "Usage: $(basename "$0") <max range value>"
|
||||
echo "Example: $(basename $0) 10 - would make a todolist with 1..10 values."
|
||||
exit 1
|
||||
}
|
||||
|
||||
list()
|
||||
{
|
||||
echo "Todolist for: $(date +%m_%d_%y)"
|
||||
for i in $(seq $arg)
|
||||
do
|
||||
echo $i
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
list
|
10
bin/welcome.sh
Executable file
10
bin/welcome.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
~/bin/greetings.sh
|
||||
echo "hostname: $HOSTNAME"
|
||||
echo "public ip: $(curl --silent ipinfo.io | grep ip | cut -f 4 -d '"')"
|
||||
echo "private ip:" $(ifconfig -a | grep inet | grep 192.168 | awk ' { print $2 }')
|
||||
#this daemon.cow usually needs to be seperately installed on a system as most do not come with it.
|
||||
fortune linux | cowsay -f /usr/share/cows/daemon.cow
|
||||
|
||||
|
Loading…
Add table
Reference in a new issue