-
Notifications
You must be signed in to change notification settings - Fork 2
/
process_functions.sh
executable file
·128 lines (100 loc) · 2.38 KB
/
process_functions.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/zsh
#
# Process functions to start/stop things as part of postactivate/deactivate
# commands. Each start should have a stop set
#
# MySQL
# check if mysqld is in the process list
# see if it is started or not
MYSQL_STOP="sudo /etc/init.d/mysql stop > /dev/null"
MYSQL_START="sudo /etc/init.d/mysql start > /dev/null"
# @todo need a much more universal way of doing this...sucks
PGSQL_STOP="sudo /etc/init.d/postgresql-8.3 stop > /dev/null"
PGSQL_START="sudo /etc/init.d/postgresql-8.3 start > /dev/null"
function zprocess_running() {
# $1 should be the process we want to look for
o=$(ps cax | grep -c "$1\$")
if [ $o -gt 0 ]; then
started=1
else
started=0
fi
return started
}
function zmysql_stop () {
zprocess_running 'mysqld'
started="$?"
if [ $started -eq 1 ]; then
eval "$MYSQL_STOP"
else
echo "MySql Not Running"
return 1
fi
# make sure that it's stopped
zprocess_running 'mysqld'
started="$?"
if [ $started -eq 1 ]; then
echo "Could not stop MySql"
return 0
fi
return 1
}
# PgSQL
# @todo combine these into one function that we pass start/stop to
function zpgsql_stop () {
zprocess_running 'postgres'
started="$?"
if [ $started -eq 1 ]; then
eval "$PGSQL_STOP"
else
echo "Postgres Not Running"
return 1
fi
# make sure that it's stopped
zprocess_running 'postgres'
started="$?"
if [ $started -eq 1 ]; then
echo "Could not stop Postgres"
return 0
fi
return 1
}
function zpgsql_start () {
zprocess_running 'postgres'
started="$?"
if [ $started -eq 0 ]; then
eval "$PGSQL_START"
else
echo "Postgres Running"
return 1
fi
# make sure that it's running
zprocess_running 'postgres'
started="$?"
if [ $started -eq 0 ]; then
echo "Could not start Postgres"
return 0
fi
return 1
}
function zmysql_start () {
zprocess_running 'mysqld'
started="$?"
if [ $started -eq 0 ]; then
eval "$MYSQL_START"
else
echo "MySQL Running"
return 1
fi
# make sure that it's running
zprocess_running 'mysqld'
started="$?"
if [ $started -eq 0 ]; then
echo "Could not start MySQL"
return 0
fi
return 1
}
# ctags
function zctags () {
}