Add upgrade script/config to installer
This commit is contained in:
parent
9bb0bca325
commit
7e3b38aaee
4 changed files with 204 additions and 5 deletions
|
|
@ -25,6 +25,7 @@ Messkit commands
|
|||
"""
|
||||
|
||||
import os
|
||||
import stat
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
|
|
@ -35,6 +36,7 @@ from rich import print as rprint
|
|||
from alembic.util.messaging import obfuscate_url_pw
|
||||
|
||||
from rattail import commands
|
||||
from rattail.files import resource_path
|
||||
|
||||
from messkit import __version__
|
||||
|
||||
|
|
@ -71,11 +73,13 @@ class Install(commands.Subcommand):
|
|||
rprint("\n\tThis tool will install and configure a new app.")
|
||||
rprint("\n\t[italic]NB. You should already have created a new database in PostgreSQL.[/italic]")
|
||||
|
||||
# get appdir path
|
||||
appdir = os.path.join(sys.prefix, 'app')
|
||||
appdir = self.basic_prompt('appdir path', appdir)
|
||||
# continue?
|
||||
if not self.basic_prompt("continue?", True, is_bool=True):
|
||||
rprint()
|
||||
sys.exit(0)
|
||||
|
||||
# appdir must not yet exist
|
||||
appdir = os.path.join(sys.prefix, 'app')
|
||||
if os.path.exists(appdir):
|
||||
rprint("\n\t[bold red]appdir already exists:[/bold red] {}\n".format(appdir))
|
||||
sys.exit(1)
|
||||
|
|
@ -106,8 +110,9 @@ class Install(commands.Subcommand):
|
|||
# make the appdir
|
||||
self.app.make_appdir(appdir)
|
||||
|
||||
# make config files
|
||||
# shared context for generated app files
|
||||
context = {
|
||||
'envdir': sys.prefix,
|
||||
'app_package': 'messkit',
|
||||
'app_title': "Messkit",
|
||||
'appdir': appdir,
|
||||
|
|
@ -115,14 +120,28 @@ class Install(commands.Subcommand):
|
|||
'pyramid_egg': 'Messkit',
|
||||
'beaker_key': 'messkit',
|
||||
}
|
||||
|
||||
# make config files
|
||||
rattail_conf = self.app.make_config_file(
|
||||
'rattail-complete', os.path.join(appdir, 'rattail.conf'),
|
||||
'rattail', os.path.join(appdir, 'rattail.conf'),
|
||||
template_path=resource_path('messkit:templates/installer/rattail.conf.mako'),
|
||||
**context)
|
||||
quiet_conf = self.app.make_config_file('quiet', appdir)
|
||||
web_conf = self.app.make_config_file(
|
||||
'web-complete', os.path.join(appdir, 'web.conf'),
|
||||
**context)
|
||||
|
||||
# make upgrade script
|
||||
path = os.path.join(appdir, 'upgrade.sh')
|
||||
self.app.render_mako_template(
|
||||
resource_path('messkit:templates/installer/upgrade.sh.mako'),
|
||||
context, output_path=path)
|
||||
os.chmod(path, stat.S_IRWXU
|
||||
| stat.S_IRGRP
|
||||
| stat.S_IXGRP
|
||||
| stat.S_IROTH
|
||||
| stat.S_IXOTH)
|
||||
|
||||
rprint("\n\tappdir created at: [bold green]{}[/bold green]".format(appdir))
|
||||
|
||||
bindir = os.path.join(sys.prefix, 'bin')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue