-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
96 lines (70 loc) · 2.49 KB
/
fabfile.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
import os, sys, re
# from fabric.api import *
# from fabric.contrib.console import confirm
from fabric2 import Connection
# .dotenv
# from os.path import join, dirname
# from dotenv import load_dotenv
# load environment variables from .env file
# dotenv_path = join(dirname(__file__), 'ENV', 'jonaso.de')
# load_dotenv(dotenv_path)
#os.environ.get('ftp_username')
#os.environ.get('ftp_password')
remotedir = os.environ.get("remotedir") # public
localdir = "public"
tarFilename = "dist/jonaso.tar.gz"
# credentials are stored in ENV/<site> file
# env.user = os.environ.get("ftp_username")
# env.hosts = [ os.environ.get("ftp_host") ]
# @task
def local_cleanup():
local("rm -f " + tarFilename)
# @task
def deploy():
print("========================================")
print("deploying to server") # + os.environ.get("ftp_host"))
print("========================================")
c = Connection(host='www.jonaso.de', port=21)
result = c.run('uname -s')
print(result.stdout.strip())
print(result.exited)
print(result.ok)
print(result.command)
print(result.connection)
print(result.connection.host)
sys.exit()
try:
# cleanup
# local_cleanup()
# compress the folder
# local("tar -zcvf %s %s" % (tarFilename, localdir))
pass
# upload the tar file to the remote host
# put(tarFilename, join(remotedir, tarFilename), use_sudo=True, mirror_local_mode=True)
# with cd(remotedir):
# untar the folder
# sudo("tar -xvf " + tarFilename)
# modify perms # TODO: check if this is necessary
# sudo("chmod 755 " + remotedir)
# drop the database
# sudo("mysqladmin -f -u%s -p\"%s\" drop %s" % (dbUsername, dbPassword, dbName))
# sudo("cp -r wordpress/dist ./");
# sudo("rm -rf ./wordpress/dist");
# sudo("cp -r wordpress/static ./");
# sudo("rm -rf ./wordpress/static");
# sudo("cp -r wordpress/favicon.* ./");
# # sudo("rm -f ./favicon.*");
# sudo("cp -r wordpress/.htaccess ./.htaccess");
# sudo("rm -f ./wordpress/.htaccess");
finally:
# cleanup
# local_cleanup()
# remote cleanup
# remove the tar file and sql file
# sudo("rm -f " + join(remotedir, localdir))
pass
if __name__ == "__main__":
deploy()