-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup~
67 lines (49 loc) · 1.56 KB
/
setup~
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
#!/bin/bash
#
# EDIT THE FOLLOWING VARIABLES
#
# Your database username
DBUSER=root
# Your database password
DBPASS=sqlroot
# Database name
DBNAME=onj
# Contest start time (by default set to 1 minute after you run setup)
STARTTIME=`date -d '1 hour 10 minutes' +"%F %H:%M:%S"`
# Contest end time (by default set to 1 hour after you run setup)
ENDTIME=`date -d '2 hours' +"%F %H:%M:%S"`
#
# DO NOT EDIT BELOW THIS UNLESS YOU REALLY KNOW WHAT YOU ARE DOING
#
#Compiling the onj.cpp
bash exe.sh
# This sets correct permissions
chmod 777 mycode*
chmod 666 myproblems*/*/statement
chmod 755 onj
# This replaces constants in settings.php and dbinit.sql
sed -i "s/dbuser/$DBUSER/g" settings.php
sed -i "s/dbpass/$DBPASS/g" settings.php
sed -i "s/dbname/$DBNAME/g" settings.php dbinit.sql
sed -i "s/STARTTIME/$STARTTIME/g" settings.php
sed -i "s/ENDTIME/$ENDTIME/g" settings.php
# This initializes the database
if [ $DBPASS ]; then
echo "drop database $DBNAME" | mysql -u"$DBUSER" -p"$DBPASS" 2> /dev/null
mysql -u"$DBUSER" -p"$DBPASS" < dbinit.sql
else
echo "drop database $DBNAME" | mysql -u"$DBUSER" 2> /dev/null
mysql -u"$DBUSER" < dbinit.sql
fi
# This generates random strings for the code and problem directories
JUNK=$(date | md5sum | md5sum)
APPEND=${JUNK:0:20}
# Uncomment these when you want to use random strings for code and problem directories
#CODEDIR=code_$APPEND
#PROBLEMDIR=problems_$APPEND
CODEDIR=code
PROBLEMDIR=problems
sed -i "s/codedir/$CODEDIR/g" settings.php
sed -i "s/problemdir/$PROBLEMDIR/g" settings.php onj
#mv code* $CODEDIR
#mv problems* $PROBLEMDIR