From 5c961dc755954d1a2f90248c81aff725cf38466c Mon Sep 17 00:00:00 2001 From: Kyle K Date: Sat, 26 May 2012 00:22:05 -0500 Subject: initial commit --- backup.sh | 29 +++++++++++++++++++++++++++++ flag_arg.sh | 16 ++++++++++++++++ gtk3-theme.sh | 2 ++ myls.sh | 9 +++++++++ play.sh | 14 ++++++++++++++ rooty 2.sh | 23 +++++++++++++++++++++++ sum.sh | 13 +++++++++++++ 7 files changed, 106 insertions(+) create mode 100755 backup.sh create mode 100755 flag_arg.sh create mode 100755 gtk3-theme.sh create mode 100755 myls.sh create mode 100755 play.sh create mode 100755 rooty 2.sh create mode 100755 sum.sh diff --git a/backup.sh b/backup.sh new file mode 100755 index 0000000..24009d9 --- /dev/null +++ b/backup.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# notes +# $0 is visible globally, in functions too + +# apparently su -c accepts a command and 1 argument +CMDL_ARGS=$@ +export CMDL_ARGS + +chk_root() +{ + if [[ ! $(id -u) -eq 0 ]]; then + echo "root user required"; + # exec works similar to fork() + exec su -c "\"$0\" $CMDL_ARGS" + exit $? + fi +} + +chk_root $@ +date=$(date +%m.%d.%y) + +echo "backing up mysql" +#mysqldump -u root -p drupal > db-drupal-${date}.sql + +echo "backing up /srv" +tar -cvjf http-${date}.tar.bz2 /srv/http +tar -cvjf git-${date}.tar.bz2 /srv/git + diff --git a/flag_arg.sh b/flag_arg.sh new file mode 100755 index 0000000..950094a --- /dev/null +++ b/flag_arg.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +VFLAG="off" +for arg in $@ + do + case "$arg" in + -v) + VFLAG="on" + ;; + esac + done + +if [[ $VFLAG == "on" ]]; then + echo "received $# arguments" +fi + diff --git a/gtk3-theme.sh b/gtk3-theme.sh new file mode 100755 index 0000000..aa24398 --- /dev/null +++ b/gtk3-theme.sh @@ -0,0 +1,2 @@ +ln -v -s /usr/share/themes/Adwaita/gtk-3.0 ~/.config/gtk-3.0 + diff --git a/myls.sh b/myls.sh new file mode 100755 index 0000000..2b80c9a --- /dev/null +++ b/myls.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +LIST=(*) +ARR_SZ=${#LIST[@]} +for ((i = 0; i < ARR_SZ; i++)) +do + echo "${LIST[$i]}" +done; + diff --git a/play.sh b/play.sh new file mode 100755 index 0000000..20133ad --- /dev/null +++ b/play.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +if [[ $1 = "bro" ]]; then + echo "you are a bro, bro!" +elif [[ -z $1 ]]; then + echo "you are a bitch" +else + echo "you still are a bitch" +fi + +if [[ x$1 = x ]]; then + echo "try your luck with arg1 next time" +fi + diff --git a/rooty 2.sh b/rooty 2.sh new file mode 100755 index 0000000..2b4dad9 --- /dev/null +++ b/rooty 2.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# $0 is visible globally, in functions too + +# apparently su -c accepts a command and 1 argument, hence we export +CMDL_ARGS=$@ +export CMDL_ARGS + +chk_root() +{ + if [[ ! $(id -u) -eq 0 ]]; then + echo "root user required"; + # exec works similar to fork() + exec su -c "\"$0\" $CMDL_ARGS" + exit $? + fi +} + +chk_root $@ +if [[ $(id -u) -eq 0 ]]; then + echo "you're root" +fi + diff --git a/sum.sh b/sum.sh new file mode 100755 index 0000000..37a7ab2 --- /dev/null +++ b/sum.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +echo -n "$1" + +for i in $*; do + if [ ! $i -eq 1 ]; then + echo -n " + $i" + fi + sum=$(($sum + $i)) +done + +echo " = $sum" + -- cgit v1.2.3