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

wils #1464

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

wils #1464

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
10baced
README.md
Wilsons-Navid Sep 25, 2024
88bdcda
the
Wilsons-Navid Sep 25, 2024
fbeb5d1
console
Wilsons-Navid Sep 25, 2024
1a121db
console.py
Wilsons-Navid Sep 25, 2024
a5c074d
wils
Wilsons-Navid Sep 25, 2024
ff73bcd
testconsole
Wilsons-Navid Sep 25, 2024
63514a9
filetest
Wilsons-Navid Sep 25, 2024
35047c2
setupsql
Wilsons-Navid Sep 25, 2024
d95d7f9
dgt
Wilsons-Navid Sep 25, 2024
27ac5f9
test
Wilsons-Navid Sep 27, 2024
268907f
db_storage
Wilsons-Navid Sep 27, 2024
0f33217
state.py
Wilsons-Navid Sep 27, 2024
20073f3
city.py
Wilsons-Navid Sep 27, 2024
07e5285
init
Wilsons-Navid Sep 27, 2024
5677b75
base_model
Wilsons-Navid Sep 27, 2024
7112dcf
console.py
Wilsons-Navid Sep 27, 2024
44d24d9
console
Wilsons-Navid Sep 27, 2024
4710e67
cons
Wilsons-Navid Sep 27, 2024
8b7ee14
console
Wilsons-Navid Sep 27, 2024
8262ac6
console
Wilsons-Navid Sep 27, 2024
c420dac
task-user
Wilsons-Navid Sep 27, 2024
8218df6
place
Usanas7 Sep 27, 2024
566cd7a
users
Usanas7 Sep 27, 2024
dc67f44
places
Usanas7 Sep 27, 2024
e0a31f3
places
Usanas7 Sep 27, 2024
2bd5343
clone
Usanas7 Sep 27, 2024
6f37023
DBStorage - Place
Usanas7 Sep 27, 2024
02aa88c
DBStorage - Review
Usanas7 Sep 27, 2024
ddc3c13
DBStorage - Amenity... and BOOM!
Usanas7 Sep 27, 2024
ad35a4f
basemodel
Usanas7 Sep 27, 2024
73f2690
test engine
Usanas7 Sep 27, 2024
96740a3
test uers
Usanas7 Sep 27, 2024
f6cb1db
tests
Usanas7 Sep 27, 2024
d283c5d
file
Usanas7 Sep 27, 2024
dfb7b12
webstatic.sh
Wilsons-Navid Oct 2, 2024
9831690
web_stat.sh
Wilsons-Navid Oct 2, 2024
08f2466
pack_web
Wilsons-Navid Oct 2, 2024
296d85b
deploy
Wilsons-Navid Oct 2, 2024
e3a4908
3deploy
Wilsons-Navid Oct 2, 2024
71801cc
wilsdep
Wilsons-Navid Oct 2, 2024
ba12203
debug
Wilsons-Navid Oct 2, 2024
dea6033
gh
Wilsons-Navid Oct 4, 2024
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
18 changes: 18 additions & 0 deletions 0-setup_web_static.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Script that sets up my web servers for the deployment of web_static
sudo apt-get -y update
sudo apt-get -y install nginx
sudo service nginx start
# Creating parent directories
sudo mkdir -p /data/web_static/shared/
sudo mkdir -p /data/web_static/releases/test/
# Creating a fake HTML file with simple content
echo 'Rethics' | sudo tee /data/web_static/releases/test/index.html
#Creating a symbolic link
ln -sf /data/web_static/releases/test/ /data/web_static/current
# Giving ownership of the /data/ folder to the ubuntu user AND group
sudo chown -R ubuntu:ubuntu /data/
# Updating the Nginx configuration to serve the content of /data/web_static/current/ to hbnb_static
sed -i "38i location /hbnb_static/ { alias /data/web_static/current/; }" /etc/nginx/sites-available/default
# Restarting Nginx
sudo service nginx restart
22 changes: 22 additions & 0 deletions 1-pack_web_static.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/python3
"""Fabric script that generates a .tgz archive from the contents of the"""


from fabric.api import local
from datetime import datetime
import os


def do_pack():
"""Generates a .tgz archive from the contents
of the web_static folder"""
now = datetime.now()
now = now.strftime('%Y%m%d%H%M%S')
archive_path = 'versions/web_static_' + now + '.tgz'

local('mkdir -p versions/')
result = local('tar -cvzf {} web_static/'.format(archive_path))

if result.succeeded:
return archive_path
return None
29 changes: 29 additions & 0 deletions 2-do_deploy_web_static.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/python3
"""Fabric script that distributes an archive to your web servers"""
from fabric.api import env, put, run
from os.path import exists

env.hosts = ["3.88.201.199", "3.87.90.59"]
env.user = "ubuntu"
env.key = "~/.ssh/id_rsa"


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

import os
from fabric.api import env, local, put, run
from datetime import datetime
from os.path import exists

env.hosts = ["98.84.116.96", "3.90.179.12"]
env.user = "ubuntu"
env.key = "~/.ssh/id_rsa"


def do_pack():
"""Create a .tgz archive from the web_static folder."""
time_stamp = datetime.now().strftime("%Y%m%d%H%M%S")
local("mkdir -p versions")
archive_path = "versions/web_static_{}.tgz".format(time_stamp)
local("tar -cvzf {} web_static".format(archive_path))
if os.path.exists(archive_path):
return archive_path
else:
return None


def do_deploy(archive_path):
"""Distribute the archive to web servers and deploy it."""
if not exists(archive_path):
return False
try:
file_name = archive_path.split("/")[-1]
name = file_name.split(".")[0]
path_name = "/data/web_static/releases/" + name
put(archive_path, "/tmp/")
run("mkdir -p {}/".format(path_name))
run('tar -xzf /tmp/{} -C {}/'.format(file_name, path_name))
run("rm /tmp/{}".format(file_name))
run("mv {}/web_static/* {}".format(path_name, path_name))
run("rm -rf {}/web_static".format(path_name))
run('rm -rf /data/web_static/current')
run('ln -s {}/ /data/web_static/current'.format(path_name))
return True
except Exception:
return False


def deploy():
"""Create and distribute an archive to web servers."""
archive_path = do_pack()
if not archive_path:
return False

return do_deploy(archive_path)
Loading