-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·74 lines (53 loc) · 1.45 KB
/
run.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
#!/bin/bash
WD=`pwd`
PORT=$[RANDOM%1000+1024]
PORT=2265
apache=""
if [[ -f httpd-minimal.conf ]]; then
apache=`command -v httpd`
if [[ "" == $apache ]]; then apache=`command -v apache2`; fi
fi
if [[ "" == $apache ]]; then
cd www
php=php
if [[ -x /usr/bin/php8 ]]; then php=php8; fi
echo "this application is available at http://localhost:$PORT"
$php -S localhost:$PORT _mvp.php
cd $WD
else
data="`pwd`/data"
access_log="$data/access.log"
config="$data/httpd.conf"
pidFile="$data/httpd.pid"
[[ -d $data ]] || mkdir -p $data
[[ -d $data ]] || exit 0
[[ -f $data/.gitignore ]] || echo '*' >$data/.gitignore
if [ "$1" == "kill" ]; then
if [[ -f $pidFile ]]; then
kill `cat $pidFile`
if [[ -f $pidFile ]]; then
rm $pidFile
fi
fi
else
if [[ ! -f $config ]]; then
cp httpd-minimal.conf $config
echo "CustomLog $access_log common" >>$config
echo "DocumentRoot `pwd`/www" >>$config
echo "<Directory `pwd`/www>" >>$config
echo " AllowOverride all" >>$config
echo " Require all granted" >>$config
echo "</Directory>" >>$config
fi
if [[ -f $pidFile ]] ; then
echo "running ..`cat $pidFile`"
else
[[ ! -f $access_log ]] || rm $access_log
echo "this application is available at http://localhost:$PORT"
$apache -DFOREGROUND \
-f $config \
-c "Listen $PORT" \
-c "PidFile $data/httpd.pid"
fi
fi
fi