Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Milka #1500

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open

Milka #1500

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
80b0d02
new changes
DLOADIN Jan 21, 2025
ff08213
new changes
DLOADIN Jan 21, 2025
ffc8270
new changes
DLOADIN Jan 21, 2025
5a2920d
Console file
milkakeza Jan 22, 2025
1c0f009
sql
DLOADIN Jan 22, 2025
2ddf7ef
milka
DLOADIN Jan 22, 2025
9db76c9
Console file updated
milkakeza Jan 22, 2025
3d89dd1
Console file updated
milkakeza Jan 22, 2025
23c813a
Merge pull request #1 from DLOADIN/Milka
DLOADIN Jan 22, 2025
d003874
Console file updated
milkakeza Jan 22, 2025
e3fd702
FileStorageUpdated
milkakeza Jan 22, 2025
8d21aba
push
DLOADIN Jan 22, 2025
32b3fe6
Merge branch 'master' of https://github.com/DLOADIN/alu-AirBnB_clone_v2
DLOADIN Jan 22, 2025
129c6b6
FileStorageUpdated
milkakeza Jan 22, 2025
0e37716
Merge branch 'master' of https://github.com/DLOADIN/alu-AirBnB_clone_v2
DLOADIN Jan 22, 2025
6589a0c
push
DLOADIN Jan 22, 2025
860a9cb
Console file updated
milkakeza Jan 22, 2025
cc08aa0
FileStorageUpdated
milkakeza Jan 22, 2025
b894e39
FileStorageUpdated
milkakeza Jan 22, 2025
573f71f
push
DLOADIN Jan 22, 2025
ed66ced
Merge branch 'master' of https://github.com/DLOADIN/alu-AirBnB_clone_v2
DLOADIN Jan 22, 2025
6c9cd68
BaseModelUpdated
milkakeza Jan 23, 2025
b983997
CityFileUpdated
milkakeza Jan 23, 2025
bf63579
StateFileUpdated
milkakeza Jan 23, 2025
9ebf1e6
InitFileUpdated
milkakeza Jan 23, 2025
427262e
DataBaseStorage
milkakeza Jan 23, 2025
d1511a1
UserFileUpdated
milkakeza Jan 23, 2025
50824f9
push
DLOADIN Jan 23, 2025
20a4045
push
DLOADIN Jan 23, 2025
97239c8
new onw
DLOADIN Jan 23, 2025
cf270f5
number two
DLOADIN Jan 23, 2025
7b9cd24
TestConsoleFile
milkakeza Jan 24, 2025
68cd37f
TestFilleStorage
milkakeza Jan 24, 2025
c270b91
TestDB
milkakeza Jan 24, 2025
9498b0a
FileStorage
milkakeza Jan 24, 2025
319fd19
another one
DLOADIN Jan 25, 2025
5c69b7f
pull one
DLOADIN Jan 25, 2025
fb228e2
new changes
DLOADIN Jan 25, 2025
0ef662d
new changes 1
DLOADIN Jan 25, 2025
784d7d3
new changes 1
DLOADIN Jan 25, 2025
11f9600
lol
DLOADIN Jan 25, 2025
49f9f65
sasa
DLOADIN Jan 25, 2025
d113609
Create 0-setup_web_static.sh
DLOADIN Feb 7, 2025
f8cd9c7
Create 1-pack_web_static.py
DLOADIN Feb 7, 2025
d3786dd
Create 2-do_deploy_web_static.py
DLOADIN Feb 7, 2025
e93dc79
Create 3-deploy_web_static.py
DLOADIN Feb 7, 2025
0a823b1
bash
Feb 7, 2025
0a637e3
new
Feb 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions 0-setup_web_static.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# script that sets up web servers for the deployment of web_statics
sudo apt-get update
sudo apt-get -y install nginx
sudo ufw allow 'Nginx HTTP'

sudo mkdir -p /data/
sudo mkdir -p /data/web_static/
sudo mkdir -p /data/web_static/releases/
sudo mkdir -p /data/web_static/shared/
sudo mkdir -p /data/web_static/releases/test/
sudo touch /data/web_static/releases/test/index.html
sudo echo "<html>
<head>
</head>
<body>
Holberton School
</body>
</html>" | sudo tee /data/web_static/releases/test/index.html

sudo ln -s -f /data/web_static/releases/test/ /data/web_static/current

sudo chown -R ubuntu:ubuntu /data/

sudo sed -i '/listen 80 default_server/a location /hbnb_static { alias /data/web_static/current/;}' /etc/nginx/sites-enabled/default

sudo service nginx restart
23 changes: 23 additions & 0 deletions 1-pack_web_static.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/python3
"""
Fabric script to genereate tgz archive
execute: fab -f 1-pack_web_static.py do_pack
"""

from datetime import datetime
from fabric.api import *


def do_pack():
"""
making an archive on web_static folder
"""

time = datetime.now()
archive = 'web_static_' + time.strftime("%Y%m%d%H%M%S") + '.' + 'tgz'
local('mkdir -p versions')
create = local('tar -cvzf versions/{} web_static'.format(archive))
if create is not None:
return archive
else:
return None
30 changes: 30 additions & 0 deletions 2-do_deploy_web_static.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/python3
"""
Fabric script based on the file 1-pack_web_static.py that distributes an
archive to the web servers
"""

from fabric.api import put, run, env
from os.path import exists
env.hosts = ['54.89.109.87', '100.25.190.21']


def do_deploy(archive_path):
"""distributes an archive to the web servers"""
if exists(archive_path) is False:
return False
try:
file_n = archive_path.split("/")[-1]
no_ext = file_n.split(".")[0]
path = "/data/web_static/releases/"
put(archive_path, '/tmp/')
run('mkdir -p {}{}/'.format(path, no_ext))
run('tar -xzf /tmp/{} -C {}{}/'.format(file_n, path, no_ext))
run('rm /tmp/{}'.format(file_n))
run('mv {0}{1}/web_static/* {0}{1}/'.format(path, no_ext))
run('rm -rf {}{}/web_static'.format(path, no_ext))
run('rm -rf /data/web_static/current')
run('ln -s {}{}/ /data/web_static/current'.format(path, no_ext))
return True
except:
return False
54 changes: 54 additions & 0 deletions 3-deploy_web_static.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/python3
"""
Fabric script based on the file 2-do_deploy_web_static.py that creates and
distributes an archive to the web servers

execute: fab -f 3-deploy_web_static.py deploy -i ~/.ssh/id_rsa -u ubuntu
"""

from fabric.api import env, local, put, run
from datetime import datetime
from os.path import exists, isdir
env.hosts = ['54.160.77.90', '10.25.190.21']


def do_pack():
"""generates a tgz archive"""
try:
date = datetime.now().strftime("%Y%m%d%H%M%S")
if isdir("versions") is False:
local("mkdir versions")
file_name = "versions/web_static_{}.tgz".format(date)
local("tar -cvzf {} web_static".format(file_name))
return file_name
except:
return None


def do_deploy(archive_path):
"""distributes an archive to the web servers"""
if exists(archive_path) is False:
return False
try:
file_n = archive_path.split("/")[-1]
no_ext = file_n.split(".")[0]
path = "/data/web_static/releases/"
put(archive_path, '/tmp/')
run('mkdir -p {}{}/'.format(path, no_ext))
run('tar -xzf /tmp/{} -C {}{}/'.format(file_n, path, no_ext))
run('rm /tmp/{}'.format(file_n))
run('mv {0}{1}/web_static/* {0}{1}/'.format(path, no_ext))
run('rm -rf {}{}/web_static'.format(path, no_ext))
run('rm -rf /data/web_static/current')
run('ln -s {}{}/ /data/web_static/current'.format(path, no_ext))
return True
except:
return False


def deploy():
"""creates and distributes an archive to the web servers"""
archive_path = do_pack()
if archive_path is None:
return False
return do_deploy(archive_path)
3 changes: 3 additions & 0 deletions AUTHORS
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

Ezra Nobrega <ezra.nobrega@outlook.com>
Justin Majetich <justinmajetich@gmail.com>
Manzi David <m.david@alustudent.com>
Isingizwe Keza Milka <m.isingizwe1@alustudent.com>

Empty file modified README.md
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions alu-AirBnB_clone_v2
Submodule alu-AirBnB_clone_v2 added at a234f7
Loading