Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 86 lines (76 sloc) 1.849 kb
1e8e23e @Gcool functions
authored
1 #Create archive
2 compress () {
3 if [ -n "$1" ] ; then
4 FILE=$1
5 case $FILE in
6 *.tar) shift && tar cf $FILE $* ;;
7 *.tar.bz2) shift && tar cjf $FILE $* ;;
8 *.tar.gz) shift && tar czf $FILE $* ;;
9 *.tgz) shift && tar czf $FILE $* ;;
10 *.zip) shift && zip $FILE $* ;;
11 *.rar) shift && rar $FILE $* ;;
12 esac
13 else
14 echo "usage: compress <archive.tar.gz> <archive> <files>"
15 fi
16 }
17
18 #Unpack archive
19 unpack() {
20 if [ -f $1 ] ; then
21 case $1 in
22 *.tar.bz2) tar xjf $1 ;;
23 *.tbz2) tar xjf $1 ;;
24 *.tar.gz) tar xzf $1 ;;
25 *.tgz) tar xzf $1 ;;
26 *.bz2) bunzip2 $1 ;;
27 *.rar) unrar x $1 ;;
28 *.gz) gunzip $1 ;;
29 *.tar) tar xf $1 ;;
30 *.zip) unzip $1 ;;
31 *.Z) uncompress $1 ;;
32 *.7z) 7z x $1 ;;
33 *) echo -e ${YELLOW}"'$1' cannot be unpacked"${RESET} ;;
34 esac
35 else
36 echo -e ${YELLOW}"'$1' is an invalid file"${RESET}
37 fi
38 }
39
40 #Generate random password
41 genpasswd() {
42 local l=$1
43 [ "$l" == "" ] && l=16
44 tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs
45 }
46
47 #Fix permissions
48 permfix() {
49 for dir in "$@"; do
50 find "$dir" -type d -exec chmod 755 {} \;
51 find "$dir" -type f -exec chmod 644 {} \;
52 done
53 }
54
55 #chown
56 mkmine() {
57 sudo chown -R ${USER}:${USER} $1
58 }
59
60 mkroot() {
61 sudo chown -R root:root $1
62 }
63
64 #start/restart/stop services
65 start() {
66 sudo rc.d start $1
67 }
68
69 restart() {
70 sudo rc.d restart $1
71 }
72
73 stop() {
74 sudo rc.d stop $1
75 }
76
77 #repeat command x times
78 function repeat()
79 {
80 local i max
81 max=$1; shift;
82 for ((i=1; i <= max ; i++)); do
83 eval "$@";
84 done
85 }
Something went wrong with that request. Please try again.