summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle K <kylek389@gmail.com>2012-05-26 00:22:05 -0500
committerKamil Kaminski <kyle@kkaminsk.com>2012-05-26 00:22:05 -0500
commit5c961dc755954d1a2f90248c81aff725cf38466c (patch)
tree73aebdd6101d798355149d6499186ef9a2ef866b
downloadscripts-5c961dc755954d1a2f90248c81aff725cf38466c.tar.gz
scripts-5c961dc755954d1a2f90248c81aff725cf38466c.tar.bz2
scripts-5c961dc755954d1a2f90248c81aff725cf38466c.zip
initial commit
-rwxr-xr-xbackup.sh29
-rwxr-xr-xflag_arg.sh16
-rwxr-xr-xgtk3-theme.sh2
-rwxr-xr-xmyls.sh9
-rwxr-xr-xplay.sh14
-rwxr-xr-xrooty 2.sh23
-rwxr-xr-xsum.sh13
7 files changed, 106 insertions, 0 deletions
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"
+