-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sh
More file actions
executable file
·102 lines (87 loc) · 2.27 KB
/
init.sh
File metadata and controls
executable file
·102 lines (87 loc) · 2.27 KB
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
#!/bin/bash
# initialize the working folder
exec_cmd(){
echo "$*"
eval "$*"
}
rundir=$(python -c "import os; print(os.path.realpath(os.path.dirname('$0')))")
cd $rundir
filelist="
$rundir/db.sqlite3
"
dirlist="
$rundir/proj/pred/static/tmp
$rundir/proj/pred/static/result
$rundir/proj/pred/static/md5
$rundir/proj/pred/static/log
$rundir/proj/pred/static/log/stat
$rundir/proj/pred/static/log/divided
"
echo "setting up file permissions"
platform_info=`python -mplatform | tr '[:upper:]' '[:lower:]'`
platform=
case $platform_info in
*centos*)platform=centos;;
*redhat*) platform=redhat;;
*ubuntu*|*debian*)platform=ubuntu;;
*darwin)platform=osx;;
*)platform=other;;
esac
case $platform in
centos|redhat) user=apache;group=apache;;
ubuntu) user=www-data;group=www-data;;
osx) user=_www;group=_www;;
other)echo Unrecognized plat form $platform_info; exit 1;;
esac
# change folder permission and add user to the apache group
myuser=$(whoami)
sudo usermod -a -G $group $myuser
sudo chgrp $group $rundir
sudo chmod 775 $rundir
for file in $filelist; do
if [ -f "$file" ];then
exec_cmd "sudo chown $user:$group $file"
fi
done
echo "create dirs"
for dir in $dirlist; do
if [ ! -d $dir ];then
exec_cmd "sudo mkdir -p $dir"
fi
exec_cmd "sudo chmod 755 $dir"
exec_cmd "sudo chown -R $user:$group $dir"
done
logfile_submit=$rundir/proj/pred/static/log/submitted_seq.log
if [ ! -f $logfile_submit ];then
exec_cmd "sudo touch $logfile_submit"
fi
exec_cmd "sudo chmod 644 $logfile_submit"
exec_cmd "sudo chown $user:$group $logfile_submit"
# fix the settings.py
if [ ! -f $rundir/proj/settings.py -a ! -L $rundir/proj/settings.py ];then
pushd $rundir/proj; ln -s pro_settings.py settings.py; popd;
fi
path_config=$rundir/proj/pred/config
configfilelist="
$path_config/alert_email.txt
$path_config/black_iplist.txt
$path_config/computenode.txt
$path_config/vip_email.txt
$path_config/forward_email.txt
$path_config/auth_iplist.txt
"
for f in $configfilelist; do
touch $f
done
# create example result
example_folder_list="
example_oneseq
example_multiseq
"
pushd $rundir/proj/pred/static/result
for item in $example_folder_list; do
if [ ! -d $item ]; then
sudo ln -s ../download/examples/$item .
fi
done
popd