Compare commits
11 Commits
branches
...
teststuff3
Author | SHA1 | Date | |
---|---|---|---|
74103cc401 | |||
6a27b88465 | |||
d91df030be | |||
2d027afa29 | |||
27afb67a17 | |||
61af6f62b6 | |||
3ff71a5114 | |||
84ad1d92ec | |||
721e94e1e8 | |||
06c0e8b9dd | |||
f831addb5e |
30
create.sh
30
create.sh
@ -3,35 +3,42 @@
|
|||||||
name="$1"
|
name="$1"
|
||||||
sshURL="$2"
|
sshURL="$2"
|
||||||
|
|
||||||
|
nodePort=`./random_port.py`
|
||||||
|
|
||||||
eval "$(ssh-agent -s)"
|
eval "$(ssh-agent -s)"
|
||||||
ssh-add /root/.ssh/id_github_rsa
|
ssh-add /root/.ssh/id_github_rsa
|
||||||
mkdir /var/www/gitwrapper/$name
|
mkdir /var/www/gitwrapper/$name
|
||||||
cd /var/www/gitwrapper/$name
|
cd /var/www/gitwrapper/$name
|
||||||
|
chmod 777 .
|
||||||
echo `pwd`
|
echo `pwd`
|
||||||
|
|
||||||
DJANGO_SETTINGS_MODULE=project.settings.prod
|
DJANGO_SETTINGS_MODULE=project.settings.prod
|
||||||
export DJANGO_SETTINGS_MODULE=project.settings.prod
|
export DJANGO_SETTINGS_MODULE=project.settings.prod
|
||||||
|
|
||||||
git clone $sshURL .
|
git clone $sshURL .
|
||||||
virtualenv ./env
|
|
||||||
source env/bin/activate
|
./scripts/setup.sh
|
||||||
pip install -r requirements.txt
|
|
||||||
cp /var/www/local_settings.py project/settings/local_settings.py
|
cp /var/www/local_settings.py project/settings/local_settings.py
|
||||||
echo "BRANCH = '$name'" >> project/settings/local_settings.py
|
echo "BRANCH = '$name'" >> project/settings/local_settings.py
|
||||||
|
|
||||||
python manage.py createcachetable
|
# set up project from prod, load database
|
||||||
python3 manage.py migrate
|
git checkout prod
|
||||||
python3 manage.py loaddata "/var/www/django.json"
|
|
||||||
|
./manage.py createcachetable
|
||||||
|
./manage.py migrate
|
||||||
|
./manage.py loaddata /var/www/django.json
|
||||||
|
|
||||||
git checkout $name
|
git checkout $name
|
||||||
|
|
||||||
pip install -r requirements.txt
|
./scripts/setup.sh
|
||||||
|
|
||||||
python3 manage.py collectstatic --noinput
|
# python3 manage.py collectstatic --noinput
|
||||||
python3 manage.py migrate
|
./manage.py migrate
|
||||||
chmod 777 .
|
|
||||||
chmod 777 db.sqlite3
|
chmod 777 db.sqlite3
|
||||||
|
|
||||||
|
|
||||||
|
# set up apache vhost
|
||||||
echo "<VirtualHost *:80>" > /etc/apache2/sites-enabled/$name.conf
|
echo "<VirtualHost *:80>" > /etc/apache2/sites-enabled/$name.conf
|
||||||
echo " ServerName $name.staging.bytedev.co" >> /etc/apache2/sites-enabled/$name.conf
|
echo " ServerName $name.staging.bytedev.co" >> /etc/apache2/sites-enabled/$name.conf
|
||||||
echo " Alias /static /var/www/gitwrapper/$name/staticfiles" >> /etc/apache2/sites-enabled/$name.conf
|
echo " Alias /static /var/www/gitwrapper/$name/staticfiles" >> /etc/apache2/sites-enabled/$name.conf
|
||||||
@ -40,7 +47,6 @@ echo " WSGIProcessGroup $name" >> /etc/apache2/sites-enabled/$name.conf
|
|||||||
echo " WSGIScriptAlias / /var/www/gitwrapper/$name/project/wsgi.py" >> /etc/apache2/sites-enabled/$name.conf
|
echo " WSGIScriptAlias / /var/www/gitwrapper/$name/project/wsgi.py" >> /etc/apache2/sites-enabled/$name.conf
|
||||||
echo "</VirtualHost>" >> /etc/apache2/sites-enabled/$name.conf
|
echo "</VirtualHost>" >> /etc/apache2/sites-enabled/$name.conf
|
||||||
|
|
||||||
|
/usr/sbin/service apache2 restart
|
||||||
service apache2 restart
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -5,6 +5,6 @@ sshURL="$2"
|
|||||||
rm -rf /var/www/gitwrapper/$name
|
rm -rf /var/www/gitwrapper/$name
|
||||||
rm /etc/apache2/sites-enabled/$name.conf
|
rm /etc/apache2/sites-enabled/$name.conf
|
||||||
|
|
||||||
service apache2 reload
|
/usr/sbin/service apache2 restart
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
9
random_port.py
Executable file
9
random_port.py
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import socket
|
||||||
|
|
||||||
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
s.bind(('', 0))
|
||||||
|
addr = s.getsockname()
|
||||||
|
print (addr[1])
|
||||||
|
s.close()
|
||||||
|
exit(0)
|
@ -11,20 +11,20 @@ var install_dir = '/var/www/gitwrapper/'
|
|||||||
var calls = {
|
var calls = {
|
||||||
create: function(req, res, name, sshURL){
|
create: function(req, res, name, sshURL){
|
||||||
return exec('bash /var/www/gitdeploy/create.sh '+name+' '+sshURL, function(err, stdout, stderr){
|
return exec('bash /var/www/gitdeploy/create.sh '+name+' '+sshURL, function(err, stdout, stderr){
|
||||||
|
console.log(err, stdout, stderr);
|
||||||
return res.json({ title: 'Express' });
|
return res.json({ title: stdout });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
update: function(req, res, name, sshURL){
|
update: function(req, res, name, sshURL){
|
||||||
return exec('bash /var/www/gitdeploy/update.sh '+name+' '+sshURL, function(err, stdout, stderr){
|
return exec('bash /var/www/gitdeploy/update.sh '+name+' '+sshURL, function(err, stdout, stderr){
|
||||||
|
console.log(err, stdout, stderr);
|
||||||
return res.json({ title: 'Express' });
|
return res.json({ title: stdout });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
delete: function(req, res, name, sshURL){
|
delete: function(req, res, name, sshURL){
|
||||||
return exec('bash /var/www/gitdeploy/delete.sh '+name+' '+sshURL, function(err, stdout, stderr){
|
return exec('bash /var/www/gitdeploy/delete.sh '+name+' '+sshURL, function(err, stdout, stderr){
|
||||||
|
console.log(err, stdout, stderr);
|
||||||
return res.json({ title: 'Express' });
|
return res.json({ title: stdout });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
update.sh
12
update.sh
@ -2,23 +2,25 @@
|
|||||||
name="$1"
|
name="$1"
|
||||||
sshURL="$2"
|
sshURL="$2"
|
||||||
|
|
||||||
|
# set up git to auth
|
||||||
eval "$(ssh-agent -s)"
|
eval "$(ssh-agent -s)"
|
||||||
ssh-add /root/.ssh/id_github_rsa
|
ssh-add /root/.ssh/id_github_rsa
|
||||||
|
|
||||||
DJANGO_SETTINGS_MODULE=project.settings.prod
|
DJANGO_SETTINGS_MODULE=project.settings.prod
|
||||||
export DJANGO_SETTINGS_MODULE=project.settings.prod
|
export DJANGO_SETTINGS_MODULE=project.settings.prod
|
||||||
|
|
||||||
cd /var/www/gitwrapper/$name
|
cd /var/www/gitwrapper/$name
|
||||||
|
|
||||||
source env/bin/activate
|
|
||||||
|
|
||||||
git stash
|
git stash
|
||||||
git pull --force origin $name
|
git pull --force origin $name
|
||||||
pip install -r requirements.txt
|
|
||||||
|
./scripts/setup.sh
|
||||||
|
|
||||||
python3 manage.py collectstatic --noinput
|
python3 manage.py collectstatic --noinput
|
||||||
python3 manage.py migrate
|
python3 manage.py migrate
|
||||||
|
|
||||||
chmod 777 .
|
chmod 777 .
|
||||||
chmod 777 db.sqlite3
|
chmod 777 db.sqlite3
|
||||||
service apache2 reload
|
|
||||||
|
/usr/sbin/service apache2 restart
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Reference in New Issue
Block a user