mmgen-autosign: move mountpoint /mnt/tx to /mnt/mmgen_autosign

This commit is contained in:
The MMGen Project 2023-04-18 18:35:55 +00:00
commit b80a69dd92
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
2 changed files with 31 additions and 7 deletions

View file

@ -16,17 +16,29 @@ import sys,os,asyncio
from subprocess import run,PIPE,DEVNULL
from collections import namedtuple
from .util import msg,msg_r,ymsg,rmsg,gmsg,bmsg,die,suf,fmt_list
from .util import msg,msg_r,ymsg,rmsg,gmsg,bmsg,die,suf,fmt,fmt_list
from .color import yellow,red,orange
from .wallet import Wallet
class Autosign:
dfl_mountpoint = os.path.join(os.sep,'mnt','tx')
dfl_mountpoint = os.path.join(os.sep,'mnt','mmgen_autosign')
wallet_dir = os.path.join(os.sep,'dev','shm','autosign')
disk_label_dir = os.path.join(os.sep,'dev','disk','by-label')
part_label = 'MMGEN_TX'
old_dfl_mountpoint = os.path.join(os.sep,'mnt','tx')
old_dfl_mountpoint_errmsg = f"""
Mountpoint {old_dfl_mountpoint!r} is no longer supported!
Please rename {old_dfl_mountpoint!r} to {dfl_mountpoint!r}
and update your fstab accordingly.
"""
mountpoint_errmsg_fs = """
Mountpoint {!r} does not exist or does not point
to a directory! Please create the mountpoint and add an entry
to your fstab as described in this scripts help text.
"""
mn_fmts = {
'mmgen': 'words',
'bip39': 'bip39',
@ -96,9 +108,17 @@ class Autosign:
def do_mount(self):
if not os.path.isdir(self.mountpoint):
def do_die(m):
die(1,'\n' + yellow(fmt(m.strip(),indent=' ')))
if os.path.isdir(self.old_dfl_mountpoint):
do_die(self.old_dfl_mountpoint_errmsg)
else:
do_die(self.mountpoint_errmsg_fs.format(self.mountpoint))
if not os.path.ismount(self.mountpoint):
if run( ['mount',self.mountpoint], stderr=DEVNULL, stdout=DEVNULL ).returncode == 0:
msg(f'Mounting {self.mountpoint}')
msg(f'Mounting {self.mountpoint!r}')
self.have_msg_dir = os.path.isdir(self.msg_dir)

View file

@ -32,6 +32,7 @@ from .ts_shared import *
from .input import *
from mmgen.led import LEDControl
from mmgen.autosign import Autosign
filedir_map = (
('btc',''),
@ -52,7 +53,7 @@ def init_led(simulate):
if fn:
run(['sudo','chmod','0666',fn],check=True)
def check_mountpoint(mountpoint):
def check_mountpoint(mountpoint,txdir):
if not os.path.ismount(mountpoint):
try:
run(['mount',mountpoint],check=True)
@ -60,7 +61,6 @@ def check_mountpoint(mountpoint):
except:
die(2,f'Could not mount {mountpoint}! Exiting')
txdir = joinpath(mountpoint,'tx')
if not os.path.isdir(txdir):
die(2,f'Directory {txdir} does not exist! Exiting')
@ -91,6 +91,10 @@ class TestSuiteAutosignBase(TestSuiteBase):
self.network_ids = [c+'_tn' for c in self.daemon_coins] + self.daemon_coins
as_cfg = Config()
type(as_cfg)._set_ok += ('outdir','passwd_file')
self.asi = Autosign(as_cfg)
if self.simulate and not cfg.exact_output:
die(1,red('This command must be run with --exact-output enabled!'))
@ -99,9 +103,9 @@ class TestSuiteAutosignBase(TestSuiteBase):
LEDControl.create_dummy_control_files()
if self.live:
self.mountpoint = '/mnt/tx'
self.mountpoint = self.asi.mountpoint
self.opts = ['--coins='+','.join(self.coins)]
check_mountpoint(self.mountpoint)
check_mountpoint( self.mountpoint, self.asi.tx_dir )
init_led(self.simulate)
else:
self.mountpoint = self.tmpdir