Skip to content

Commit

Permalink
improved zfs_datasets usage and adding de name supports
Browse files Browse the repository at this point in the history
  • Loading branch information
ericbsd committed Jan 3, 2024
1 parent eec8218 commit c2ad69a
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 129 deletions.
4 changes: 2 additions & 2 deletions src/add_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from gi.repository import Gtk, Gdk
import pickle
from gbi_common import password_strength
from sys_handler import set_addmin_user
from sys_handler import set_admin_user

# Directory use from the installer.
tmp = "/tmp/.gbi/"
Expand Down Expand Up @@ -50,7 +50,7 @@ def save_admin_user(self):
hf = f'/home/{uname}'
hst = f'{uname}-ghostbsd'
# Set root password
set_addmin_user(uname, name, up, shell, hf, hst)
set_admin_user(uname, name, up, shell, hf, hst)

def on_shell(self, widget):
SHELL = widget.get_active_text()
Expand Down
15 changes: 15 additions & 0 deletions src/gbi_common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
import re

be_name="default"
# Default zfs datasets layout
zfs_datasets = "/," \
"/home(mountpoint=/home)," \
"/tmp(mountpoint=/tmp|exec=on|setuid=off)," \
"/usr(mountpoint=/usr|canmount=off)," \
"/usr/ports(setuid=off)," \
"/usr/src," \
"/var(mountpoint=/var|canmount=off)," \
"/var/audit(exec=off|setuid=off)," \
"/var/crash(exec=off|setuid=off)," \
"/var/log(exec=off|setuid=off)," \
"/var/mail(atime=on)," \
"/var/tmp(setuid=off)"


# Find if pasword contain only lower case and number
def lowerCase(strg, search=re.compile(r'[^a-z]').search):
Expand Down
53 changes: 5 additions & 48 deletions src/partition_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pickle
from time import sleep
from subprocess import Popen, PIPE, STDOUT, call
from gbi_common import zfs_datasets

tmp = "/tmp/.gbi"
if not os.path.exists(tmp):
Expand Down Expand Up @@ -642,18 +643,7 @@ def create_mbr_partiton(self, drive, size, path, fs):
part_list = disk_db[drive]['partitions'][main_slice]['partition-list']

if fs == "ZFS":
layout = "/," \
"/tmp(mountpoint=/tmp|exec=on|setuid=off)," \
"/usr(mountpoint=/usr|canmount=off)," \
"/home," \
"/usr/ports(setuid=off)," \
"/usr/src," \
"/var(mountpoint=/var|canmount=off)," \
"/var/audit(exec=off|setuid=off)," \
"/var/crash(exec=off|setuid=off)" \
"/var/log(exec=off|setuid=off)," \
"/var/mail(atime=on)," \
"/var/tmp(setuid=off)"
layout = zfs_datasets
else:
layout = '/'

Expand Down Expand Up @@ -753,18 +743,7 @@ def create_gpt_partiton(self, drive, size, path, fs, efi_exist):
cf.close()

if fs == "ZFS":
layout = "/," \
"/tmp(mountpoint=/tmp|exec=on|setuid=off)," \
"/usr(mountpoint=/usr|canmount=off)," \
"/home," \
"/usr/ports(setuid=off)," \
"/usr/src," \
"/var(mountpoint=/var|canmount=off)," \
"/var/audit(exec=off|setuid=off)," \
"/var/crash(exec=off|setuid=off)" \
"/var/log(exec=off|setuid=off)," \
"/var/mail(atime=on)," \
"/var/tmp(setuid=off)"
layout = zfs_datasets
else:
layout = '/'

Expand Down Expand Up @@ -834,18 +813,7 @@ def __init__(self, path, drive, main_slice, size_left, create_size,
alpha_num += store_list_number
letter = chr(alpha_num)
if fs == "ZFS":
mountpoint = "/," \
"/tmp(mountpoint=/tmp|exec=on|setuid=off)," \
"/usr(mountpoint=/usr|canmount=off)," \
"/home," \
"/usr/ports(setuid=off)," \
"/usr/src," \
"/var(mountpoint=/var|canmount=off)," \
"/var/audit(exec=off|setuid=off)," \
"/var/crash(exec=off|setuid=off)" \
"/var/log(exec=off|setuid=off)," \
"/var/mail(atime=on)," \
"/var/tmp(setuid=off)"
mountpoint = zfs_datasets

partition = f'{main_slice}{letter}'
part_list[store_list_number] = partition
Expand Down Expand Up @@ -1015,18 +983,7 @@ def __init__(self, path, drive, size_left, create_size, mount_point, fs):
write_scheme.close()

if fs == "ZFS":
mount_point = "/," \
"/tmp(mountpoint=/tmp|exec=on|setuid=off)," \
"/usr(mountpoint=/usr|canmount=off)," \
"/home," \
"/usr/ports(setuid=off)," \
"/usr/src," \
"/var(mountpoint=/var|canmount=off)," \
"/var/audit(exec=off|setuid=off)," \
"/var/crash(exec=off|setuid=off)" \
"/var/log(exec=off|setuid=off)," \
"/var/mail(atime=on)," \
"/var/tmp(setuid=off)"
mount_point = zfs_datasets

disk_data = disk_database()
store_list_number = path[1]
Expand Down
14 changes: 7 additions & 7 deletions src/sys_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
pc_sysinstall = '/usr/local/sbin/pc-sysinstall'


def replace_patern(current, new, file):
def replace_pattern(current, new, file):
parser_file = open(file, 'r').read()
parser_patched = re.sub(current, new, parser_file)
save_parser_file = open(file, 'w')
Expand All @@ -31,18 +31,18 @@ def language_dictionary():
def localize_system(locale):
slick_greeter = "/usr/local/share/xgreeters/slick-greeter.desktop"
gtk_greeter = "/usr/local/share/xgreeters/lightdm-gtk-greeter.desktop"
replace_patern('lang=C', f'lang={locale}', '/etc/login.conf')
replace_patern('en_US', locale, '/etc/profile')
replace_patern('en_US', locale, '/usr/share/skel/dot.profile')
replace_pattern('lang=C', f'lang={locale}', '/etc/login.conf')
replace_pattern('en_US', locale, '/etc/profile')
replace_pattern('en_US', locale, '/usr/share/skel/dot.profile')

if os.path.exists(slick_greeter):
replace_patern(
replace_pattern(
'Exec=slick-greeter',
f'Exec=env LANG={locale}.UTF-8 slick-greeter',
slick_greeter
)
elif os.path.exists(gtk_greeter):
replace_patern(
replace_pattern(
'Exec=lightdm-gtk-greete',
f'Exec=env LANG={locale}.UTF-8 lightdm-gtk-greeter',
gtk_greeter
Expand Down Expand Up @@ -127,7 +127,7 @@ def timezone_dictionary():
return dictionary


def set_addmin_user(username, name, password, shell, homedir, hostname):
def set_admin_user(username, name, password, shell, homedir, hostname):
# Set Root user
run(f"echo '{password}' | pw usermod -n root -h 0", shell=True)
cmd = f"echo '{password}' | pw useradd {username} -c {name} -h 0" \
Expand Down
Loading

0 comments on commit c2ad69a

Please sign in to comment.