forked from hugsy/ctfhub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-heroku.sh
101 lines (80 loc) · 2.48 KB
/
install-heroku.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
#!/bin/bash -e
echo 'Logging in to heroku'
heroku login
echo 'Installing ctfpad'
cd /tmp
mkdir ctfpad && cd ctfpad
git clone https://github.com/hugsy/ctfpad .
heroku apps:create ctfp4d
heroku addons:create heroku-postgresql:hobby-dev
eval $(heroku config -s | grep DATABASE_URL)
DB=$(python -c "from urllib.parse import urlparse;u=urlparse('$DATABASE_URL');print(u.username,u.password,u.hostname,u.port,u.path.strip('/'))")
heroku config:set CTFPAD_HOSTNAME=ctfp4d.herokuapp.com
heroku config:set CTFPAD_DB_USER=$(echo $DB | cut -d' ' -f1)
heroku config:set CTFPAD_DB_PASSWORD=$(echo $DB | cut -d' ' -f2)
heroku config:set CTFPAD_DB_HOST=$(echo $DB | cut -d' ' -f3)
heroku config:set CTFPAD_DB_PORT=$(echo $DB | cut -d' ' -f4)
heroku config:set CTFPAD_DB_NAME=$(echo $DB | cut -d' ' -f5)
heroku config:set HEDGEDOC_URL=https://h3dgedoc.herokuapp.com
heroku config:set CTFPAD_USE_SSL=0
echo 'python-3.9.1' > runtime.txt
cat > Procfile <<'EOF'
release: python manage.py migrate
web: python manage.py runserver 0.0.0.0:$PORT --noreload
EOF
# uncomment to import previous db
#ADDON=$(heroku pg:info | grep Add-on:| cut -d: -f2)
#heroku pg:push postgres://ctfpad:p4ssw0rd@localhost:5432/ctfpad $ADDON
git push heroku master
echo 'Installing hedgedoc'
cd /tmp
mkdir hedgedoc && cd hedgedoc
git clone https://github.com/hedgedoc/hedgedoc.git .
git checkout -b fix 1.7.2
heroku create h3dgedoc
heroku config:set DATABASE_URL=$DATABASE_URL
heroku config:set CMD_DB_URL=$DATABASE_URL
heroku config:set CMD_DOMAIN=h3dgedoc.herokuapp.com
heroku config:set CMD_URL_ADDPORT=false
heroku config:set CMD_PROTOCOL_USESSL=true
heroku config:set CMD_ALLOW_ANONYMOUS=false
heroku config:set CMD_ALLOW_FREEURL=true
heroku config:set CMD_IMAGE_UPLOAD_TYPE=filesystem
heroku config:set CMD_COOKIE_POLICY=none
cat > bin/heroku <<'EOA'
#!/bin/bash
set -e
cat << EOF > .sequelizerc
var path = require('path');
module.exports = {
'config': path.resolve('config.json'),
'migrations-path': path.resolve('lib', 'migrations'),
'models-path': path.resolve('lib', 'models')
}
EOF
cat << EOF > config.json
{
"production": {
"url": "$DATABASE_URL",
"dbURL": "$DATABASE_URL",
"dialectOptions": {
"ssl": {
"require": true,
"rejectUnauthorized": false
}
},
"db": {
"dialectOptions": {
"ssl": {
"require": true,
"rejectUnauthorized": false
}
}
}
}
}
EOF
EOA
git commit -m fix bin/heroku
git push heroku fix:master
heroku logs --tail