-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.sh
executable file
·97 lines (83 loc) · 2.1 KB
/
init.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
#!/bin/bash
# initialize the working folder
exec_cmd(){
echo "$*"
eval "$*"
}
rundir=`dirname $0`
rundir=`readlink -f $rundir`
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=`python3 -mplatform | tr '[:upper:]' '[:lower:]'`
platform=
case $platform_info in
*centos*)platform=centos;;
*redhat*) platform=redhat;;
*ubuntu*|*debian*)platform=ubuntu;;
*)platform=other;;
esac
case $platform in
centos|redhat) user=apache;group=apache;;
ubuntu) user=www-data;group=www-data;;
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
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
# create allowed host
conf_file_list="
$rundir/proj/allowed_host_dev.txt
$rundir/proj/allowed_host_pro.txt
"
for file in $conf_file_list; do
if [ ! -f $file ];then
cp ${file}.example ${file}
fi
done
# create example result
example_folder_list="
example_1seq
example_56seq
"
pushd $rundir/proj/pred/static/result
for item in $example_folder_list; do
if [ ! -d $item ]; then
sudo ln -s ../download/example/$item .
fi
done
popd