Skip to content

Commit

Permalink
added some more options to lmn-appliance.
Browse files Browse the repository at this point in the history
  • Loading branch information
HappyBasher committed Jan 5, 2023
1 parent ce1ae89 commit f2eb557
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions lmn-appliance
Expand Up @@ -2,7 +2,7 @@
#
# lmn-appliance
# thomas@linuxmuster.net
# 20221126
# 20230105
#

import configparser
Expand Down Expand Up @@ -39,9 +39,12 @@ def usage(rc):
print('-v, --volumes=<volumelist> : List of lvm volumes to create (to be used together')
print(' with -l/--pvdevice). Syntax (size in GiB):')
print(' <name>:<size>,<name>:<size>,...')
print('-w, --swapsize=<size> : Swapfile size in GB (default "2").')
print('-f, --firewall=<firewallip> : Firewall/gateway ip (default *.254).')
print('-g, --gateway=<ip> : Gateway ip address (default is firewall ip).')
print('-d, --domain=<domainname> : Domainname (default linuxmuster.lan).')
print('-u, --unattended : Unattended mode, do not ask, use defaults.')
print('-b, --reboot : Reboots finally (only in unattended mode).')
print('-h, --help : Print this help.')
print('\nNote on lvm volumes:')
print('- Default value for volumes is:')
Expand All @@ -56,34 +59,41 @@ def usage(rc):

# get cli args
try:
opts, args = getopt.getopt(sys.argv[1:], "d:f:hl:n:p:t:uv:", [
"domain=", "firewall=", "help", "volumes=", "pvdevice=", "ipnet=", "profile=", "hostname=", "unattended"])
opts, args = getopt.getopt(sys.argv[1:], "bd:f:hl:n:p:t:uv:w:", [
"reboot", "domain=", "firewall=", "help", "volumes=", "swapsize=", "pvdevice=", "ipnet=", "profile=", "hostname=", "unattended"])
except getopt.GetoptError as err:
# print help information and exit:
print(err) # will print something like "option -a not recognized"
usage(2)

# default values
unattended = ''
reboot = ''
profile = ''
hostname = ''
domainname = ''
firewallip = ''
gateway = ''
ipnet = ''
volumes = ''
pvdevice = ''
swapsize = ''
profile_list = ['server', 'ubuntu']

# evaluate options
for o, a in opts:
if o in ("-u", "--unattended"):
unattended = ' -u'
if o in ("-b", "--reboot"):
reboot = ' -b'
elif o in ("-p", "--profile"):
profile = a
elif o in ("-t", "--hostname"):
hostname = ' -t ' + a
elif o in ("-v", "--volumes"):
volumes = ' -v ' + a
elif o in ("-v", "--volumes"):
swapsize = ' -w ' + a
elif o in ("-l", "--pvdevice"):
pvdevice = ' -l ' + a
elif o in ("-d", "--domain"):
Expand All @@ -92,6 +102,8 @@ for o, a in opts:
ipnet = ' -n ' + a
elif o in ("-f", "--firewall"):
firewallip = ' -f ' + a
elif o in ("-g", "--gateway"):
gateway = ' -g ' + a
elif o in ("-h", "--help"):
usage(0)
else:
Expand Down Expand Up @@ -191,5 +203,5 @@ subprocess.call('DEBIAN_FRONTEND=noninteractive echo -e "y\ny\ny\n" | apt -y ins
if profile != '':
print('## invoke lmn-prepare')
profile = ' -p ' + profile
subprocess.call('lmn-prepare -i' + unattended + profile
+ hostname + domainname + firewallip + ipnet + volumes + pvdevice, shell=True)
subprocess.call('lmn-prepare -i' + unattended + reboot + profile
+ hostname + domainname + firewallip + gateway + ipnet + volumes + pvdevice + swapsize, shell=True)

0 comments on commit f2eb557

Please sign in to comment.