├── .github
├── CODEOWNERS
└── workflows
│ ├── main.yml
│ └── project_automation.yml
├── .gitignore
├── LICENSE
├── README.md
├── gbi
├── setup.py
└── src
├── add_admin.py
├── add_users.py
├── backend-query
├── detect-laptop.sh
├── detect-nics.sh
├── detect-sheme.sh
├── detect-vmware.sh
├── detect-wifi.sh
├── disk-info.sh
├── disk-label.sh
├── disk-list.sh
├── disk-part.sh
├── enable-net.sh
├── list-components.sh
├── list-rsync-backups.sh
├── list-tzones.sh
├── query-langs.sh
├── send-logs.sh
├── setup-ssh-keys.sh
├── sys-mem.sh
├── test-live.sh
├── test-netup.sh
├── update-part-list.sh
├── xkeyboard-layouts.sh
├── xkeyboard-models.sh
└── xkeyboard-variants.sh
├── boot_manager.py
├── create_cfg.py
├── disk.png
├── end.py
├── error.py
├── gbi.desktop
├── gbiWindow.py
├── gbi_common.py
├── ghostbsd-style.css
├── image
├── G_logo.gif
├── disk.png
├── install-gbsd.png
├── install-gbsd.svg
├── install.png
├── installation.jpg
├── laptop.png
└── logo.png
├── install.py
├── installType.py
├── keyboard.py
├── language.py
├── laptop.png
├── network_setup.py
├── partition.py
├── partition_handler.py
├── setup_system.py
├── sys_handler.py
├── timezone.py
├── use_ufs.py
├── use_zfs.py
└── welcome_live.py
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # Each line is a file pattern followed by one or more owners.
2 |
3 | # These owners will be the default owners for everything in
4 | # the repo. Unless a later match takes precedence,
5 | # @global-owner1 and @global-owner2 will be requested for
6 | # review when someone opens a pull request.
7 | # * @global-owner1 @global-owner2
8 | * @ghostbsd/contributors @ghostbsd/new-contributors @ghostbsd/core-contributors @ghostbsd/project-leader
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | 'on': [pull_request]
3 |
4 | jobs:
5 | lint:
6 | runs-on: ubuntu-latest
7 | name: Verify code with Lintly-Flake8
8 | steps:
9 | - name: Checkout
10 | uses: actions/checkout@v1
11 | - name: Test action
12 | id: test
13 | uses: usama2490/lintly-flake8-github-action@v1.1
14 | with:
15 | # The GitHub API token to create reviews with
16 | token: ${{ secrets.GITHUB_TOKEN }}
17 | # Fail if "new" violations detected or "any", default "new"
18 | failIf: any
19 | # Additional arguments to pass to flake8,
20 | # default "." (current directory)
21 | args: "--ignore=E402,W503 --max-line-length=120."
22 |
--------------------------------------------------------------------------------
/.github/workflows/project_automation.yml:
--------------------------------------------------------------------------------
1 | name: Project automations
2 |
3 | on:
4 | pull_request_target:
5 | types:
6 | - opened
7 | branches:
8 | - 'master'
9 |
10 | # map fields with customized labels
11 | env:
12 | in_review: In Review
13 |
14 | jobs:
15 | pr_opened:
16 | name: pr_opened
17 | runs-on: ubuntu-latest
18 | if: github.event_name == 'pull_request_target' && github.event.action == 'opened'
19 | steps:
20 | - name: Move PR to ${{ env.in_review }}
21 | uses: leonsteinhaeuser/project-beta-automations@v2.1.0
22 | with:
23 | gh_token: ${{ secrets.MY_GITHUB_TOKEN }}
24 | # user: ghostbsd
25 | organization: ghostbsd
26 | project_id: 4
27 | resource_node_id: ${{ github.event.pull_request.node_id }}
28 | status_value: ${{ env.in_review }}
29 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.py[cod]
2 |
3 | # C extensions
4 | *.so
5 |
6 | # Packages
7 | *.egg
8 | *.egg-info
9 | dist
10 | build
11 | eggs
12 | parts
13 | bin
14 | var
15 | sdist
16 | develop-eggs
17 | .installed.cfg
18 | lib
19 | lib64
20 | __pycache__
21 |
22 | # Installer logs
23 | pip-log.txt
24 |
25 | # Unit test / coverage reports
26 | .coverage
27 | .tox
28 | nosetests.xml
29 |
30 | # Translations
31 | *.mo
32 |
33 | # Mr Developer
34 | .mr.developer.cfg
35 | .project
36 | .pydevproject
37 | .idea*
38 | .settings*
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011-2023, GhostBSD
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification,
5 | are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | list of conditions and the following disclaimer in the documentation and/or
12 | other materials provided with the distribution.
13 |
14 | * Neither the name of the GhostBSD nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | gbi
2 | ===
3 |
4 | GBI is a graphical interface for pc-sysinstall and it is the installer for GhostBSD.
5 |
6 | To test this code in your environment run "python setup.py install" as root.
7 |
--------------------------------------------------------------------------------
/gbi:
--------------------------------------------------------------------------------
1 | #!/usr/local/bin/python
2 | from sys import path
3 | import os
4 | import shutil
5 | import gi
6 | gi.require_version('Gtk', '3.0')
7 | from gi.repository import Gtk
8 |
9 | if os.path.exists('/tmp/.gbi'):
10 | shutil.rmtree('/tmp/.gbi')
11 |
12 | installer = "/usr/local/lib/gbi/"
13 | # path.append("/home/ericbsd/gbi/src/")
14 | path.append(installer)
15 |
16 | from gbiWindow import MainWindow
17 | import os
18 | import shutil
19 |
20 |
21 | def main():
22 | Gtk.main()
23 | return 0
24 |
25 |
26 | if __name__ == "__main__":
27 | MainWindow()
28 | main()
29 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | import os
5 | import sys
6 | # from glob import glob
7 | from setuptools import setup
8 |
9 | # import DistUtilsExtra.command.build_extra
10 | # import DistUtilsExtra.command.build_i18n
11 | # import DistUtilsExtra.command.clean_i18n
12 |
13 | # to update i18n .mo files (and merge .pot file into .po files) run on Linux:
14 | # ,,python setup.py build_i18n -m''
15 |
16 | # silence pyflakes, __VERSION__ is properly assigned below...
17 | __VERSION__ = '10.6'
18 | # for line in file('networkmgr').readlines():
19 | # if (line.startswith('__VERSION__')):
20 | # exec(line.strip())
21 | PROGRAM_VERSION = __VERSION__
22 |
23 |
24 | def datafilelist(installbase, sourcebase):
25 | datafileList = []
26 | for root, subFolders, files in os.walk(sourcebase):
27 | fileList = []
28 | for f in files:
29 | fileList.append(os.path.join(root, f))
30 | datafileList.append((root.replace(sourcebase, installbase), fileList))
31 | return datafileList
32 | # '{prefix}/share/man/man1'.format(prefix=sys.prefix), glob('data/*.1')),
33 |
34 |
35 | prefix = sys.prefix
36 |
37 | lib_gbi = [
38 | 'src/boot_manager.py',
39 | 'src/create_cfg.py',
40 | 'src/end.py',
41 | 'src/error.py',
42 | 'src/gbiWindow.py',
43 | 'src/gbi_common.py',
44 | 'src/ghostbsd-style.css',
45 | 'src/install.py',
46 | 'src/installType.py',
47 | 'src/keyboard.py',
48 | 'src/language.py',
49 | 'src/partition.py',
50 | 'src/partition_handler.py',
51 | 'src/setup_system.py',
52 | 'src/sys_handler.py',
53 | 'src/timezone.py',
54 | 'src/use_ufs.py',
55 | 'src/use_zfs.py',
56 | 'src/add_admin.py',
57 | 'src/add_users.py',
58 | 'src/welcome_live.py',
59 | 'src/network_setup.py',
60 | 'src/disk.png',
61 | 'src/laptop.png'
62 | ]
63 |
64 | lib_gbi_image = [
65 | 'src/image/G_logo.gif',
66 | 'src/image/install-gbsd.png',
67 | 'src/image/logo.png',
68 | 'src/image/disk.png',
69 | 'src/image/laptop.png',
70 | 'src/image/installation.jpg'
71 | ]
72 |
73 | lib_gbi_backend_query = [
74 | 'src/backend-query/detect-laptop.sh',
75 | 'src/backend-query/detect-nics.sh',
76 | 'src/backend-query/detect-sheme.sh',
77 | 'src/backend-query/detect-vmware.sh',
78 | 'src/backend-query/detect-wifi.sh',
79 | 'src/backend-query/disk-info.sh',
80 | 'src/backend-query/disk-label.sh',
81 | 'src/backend-query/disk-list.sh',
82 | 'src/backend-query/disk-part.sh',
83 | 'src/backend-query/enable-net.sh',
84 | 'src/backend-query/list-components.sh',
85 | 'src/backend-query/list-rsync-backups.sh',
86 | 'src/backend-query/list-tzones.sh',
87 | 'src/backend-query/query-langs.sh',
88 | 'src/backend-query/send-logs.sh',
89 | 'src/backend-query/setup-ssh-keys.sh',
90 | 'src/backend-query/sys-mem.sh',
91 | 'src/backend-query/test-live.sh',
92 | 'src/backend-query/test-netup.sh',
93 | 'src/backend-query/update-part-list.sh',
94 | 'src/backend-query/xkeyboard-layouts.sh',
95 | 'src/backend-query/xkeyboard-models.sh',
96 | 'src/backend-query/xkeyboard-variants.sh'
97 | ]
98 |
99 | data_files = [
100 | (f'{prefix}/share/applications', ['src/gbi.desktop']),
101 | (f'{prefix}/lib/gbi', lib_gbi),
102 | (f'{prefix}/lib/gbi/backend-query', lib_gbi_backend_query),
103 | (f'{prefix}/lib/gbi/image', lib_gbi_image)
104 | ]
105 |
106 | data_files.extend(datafilelist(f'{prefix}/share/locale', 'build/mo'))
107 |
108 | # cmdclass ={
109 | # "build" : DistUtilsExtra.command.build_extra.build_extra,
110 | # "build_i18n" : DistUtilsExtra.command.build_i18n.build_i18n,
111 | # "clean": DistUtilsExtra.command.clean_i18n.clean_i18n,
112 | # }
113 |
114 | setup(name="gbi",
115 | version=PROGRAM_VERSION,
116 | description="GBI is a GTK front end user interface for pc-sysinstall",
117 | license='BSD',
118 | author='Eric Turgeon',
119 | url='https://github/GhostBSD/gbi/',
120 | package_dir={'': '.'},
121 | data_files=data_files,
122 | # install_requires = [ 'setuptools', ],
123 | scripts=['gbi'],)
124 | # cmdclass = cmdclass,
125 |
--------------------------------------------------------------------------------
/src/add_admin.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | from gi.repository import Gtk, Gdk
4 | import pickle
5 | from gbi_common import password_strength
6 | from sys_handler import set_admin_user
7 |
8 | # Directory use from the installer.
9 | tmp = "/tmp/.gbi/"
10 | userfile = tmp + "user_admin"
11 |
12 | cssProvider = Gtk.CssProvider()
13 | cssProvider.load_from_path('/usr/local/lib/gbi/ghostbsd-style.css')
14 | screen = Gdk.Screen.get_default()
15 | styleContext = Gtk.StyleContext()
16 | styleContext.add_provider_for_screen(
17 | screen,
18 | cssProvider,
19 | Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
20 | )
21 |
22 |
23 | class AddUser:
24 |
25 | def save_selection(self):
26 | # Set admin user
27 | uf = open(userfile, 'wb')
28 | uname = self.user.get_text()
29 | name = self.name.get_text()
30 | up = self.password.get_text()
31 | shell = self.sh
32 | hf = f'/home/{uname}'
33 | hst = f'{uname}-ghostbsd'
34 | ul = [uname, name, up, shell, hf, hst]
35 | pickle.dump(ul, uf)
36 | uf.close()
37 | # Set root password
38 | rf = open('%sroot' % tmp, 'wb')
39 | rp = self.password.get_text()
40 | ul = [rp]
41 | pickle.dump(ul, rf)
42 | rf.close()
43 |
44 | def save_admin_user(self):
45 | # Set admin user
46 | uname = self.user.get_text()
47 | name = self.name.get_text()
48 | up = self.password.get_text()
49 | shell = self.sh
50 | hf = f'/home/{uname}'
51 | hst = f'{uname}-ghostbsd'
52 | # Set root password
53 | set_admin_user(uname, name, up, shell, hf, hst)
54 |
55 | def on_shell(self, widget):
56 | shell = widget.get_active_text()
57 | if shell == 'sh':
58 | self.sh = '/bin/sh'
59 | elif shell == 'csh':
60 | self.sh = '/bin/csh'
61 | elif shell == 'tcsh':
62 | self.sh = '/bin/tcsh'
63 | elif shell == 'fish':
64 | self.sh = '/usr/local/bin/fish'
65 | elif shell == 'bash':
66 | self.sh = '/usr/local/bin/bash'
67 | elif shell == 'rbash':
68 | self.sh = '/usr/local/bin/rbash'
69 | elif shell == 'zsh':
70 | self.sh = '/usr/local/bin/zsh'
71 | elif shell == 'ksh':
72 | self.sh = '/usr/local/bin/ksh93'
73 |
74 | def user_and_host(self, widget):
75 | username = self.name.get_text().split()
76 | if len(username) > 1:
77 | self.host.set_text(f"{username[0].lower()}-ghostbsd-pc")
78 | self.user.set_text(username[0].lower())
79 | else:
80 | self.host.set_text("")
81 | self.user.set_text("")
82 |
83 | def __init__(self, button3):
84 | self.vbox1 = Gtk.VBox(False, 0)
85 | self.vbox1.show()
86 | title = Gtk.Label(label="User Admin Setup", name="Header")
87 | title.set_property("height-request", 50)
88 | self.vbox1.pack_start(title, False, False, 0)
89 | admin_message = Gtk.Label(label="The initial root password will be set to the admin user password.")
90 | self.vbox1.pack_start(admin_message, False, False, 0)
91 | box2 = Gtk.VBox(False, 0)
92 | box2.set_border_width(10)
93 | self.vbox1.pack_start(box2, False, False, 0)
94 | box2.show()
95 | box2 = Gtk.VBox(False, 10)
96 | # box2.set_border_width(10)
97 | self.vbox1.pack_start(box2, False, False, 0)
98 | box2.show()
99 | label = Gtk.Label(label='User Account')
100 | label.set_use_markup(True)
101 | label.set_alignment(.2, .2)
102 | username = Gtk.Label(label="User name")
103 | self.user = Gtk.Entry()
104 | self.label2 = Gtk.Label(label="Real name")
105 | self.name = Gtk.Entry()
106 | self.name.connect("changed", self.user_and_host)
107 | self.labelpass = Gtk.Label(label="Password")
108 | self.password = Gtk.Entry()
109 | self.password.set_visibility(False)
110 | self.password.connect("changed", self.password_verification, button3)
111 | self.label4 = Gtk.Label(label="Verify Password")
112 | self.repassword = Gtk.Entry()
113 | self.repassword.set_visibility(False)
114 | self.repassword.connect("changed", self.password_verification, button3)
115 | self.label5 = Gtk.Label(label="Shell")
116 | shell = Gtk.ComboBoxText()
117 | self.sh = '/usr/local/bin/fish'
118 | # Keeping this code for future project example.
119 | shell.append_text('sh')
120 | shell.append_text('csh')
121 | shell.append_text('tcsh')
122 | shell.append_text('fish')
123 | shell.append_text('bash')
124 | shell.append_text('rbash')
125 | shell.append_text('ksh')
126 | shell.append_text('zsh')
127 | shell.set_active(3)
128 | shell.connect("changed", self.on_shell)
129 | label = Gtk.Label(label='Set Hostname')
130 | label.set_use_markup(True)
131 | label.set_alignment(0, .5)
132 | table = Gtk.Table(1, 3, True)
133 | table.set_row_spacings(10)
134 | # pcname = Gtk.Label("Hostname")
135 | self.host = Gtk.Entry()
136 | # table.attach(label, 0, 2, 0, 1)
137 | table.attach(self.label2, 0, 1, 1, 2)
138 | table.attach(self.name, 1, 2, 1, 2)
139 | # table.attach(pcname, 0, 1, 2, 3)
140 | # table.attach(self.host, 1, 2, 2, 3)
141 | table.attach(username, 0, 1, 2, 3)
142 | table.attach(self.user, 1, 2, 2, 3)
143 | table.attach(self.labelpass, 0, 1, 4, 5)
144 | table.attach(self.password, 1, 2, 4, 5)
145 | self.label3 = Gtk.Label()
146 | table.attach(self.label3, 2, 3, 4, 5)
147 | table.attach(self.label4, 0, 1, 5, 6)
148 | table.attach(self.repassword, 1, 2, 5, 6)
149 | # set image for password matching
150 | self.img = Gtk.Image()
151 | table.attach(self.img, 2, 3, 5, 6)
152 | # table.attach(self.label5, 0, 1, 6, 7)
153 | # table.attach(shell, 1, 2, 6, 7)
154 | box2.pack_start(table, False, False, 0)
155 | self.box3 = Gtk.VBox(False, 10)
156 | self.box3.set_border_width(10)
157 | self.vbox1.pack_start(self.box3, True, True, 0)
158 | self.box3.show()
159 |
160 | # self.label3 = Gtk.Label()
161 | # self.box3.pack_start(self.label3, False, False, 0)
162 |
163 | def get_model(self):
164 | return self.vbox1
165 |
166 | def password_verification(self, widget, button3):
167 | password = self.password.get_text()
168 | password_strength(password, self.label3)
169 | repassword = self.repassword.get_text()
170 | if password == repassword and password != "" and " " not in password:
171 | self.img.set_from_stock(Gtk.STOCK_YES, 5)
172 | button3.set_sensitive(True)
173 | else:
174 | self.img.set_from_stock(Gtk.STOCK_NO, 5)
175 | button3.set_sensitive(False)
176 |
--------------------------------------------------------------------------------
/src/add_users.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | from gi.repository import Gtk, Gdk
4 | import pickle
5 | from gbi_common import password_strength
6 |
7 | # Directory use from the installer.
8 | tmp = "/tmp/.gbi/"
9 | userfile = tmp + "user"
10 |
11 | cssProvider = Gtk.CssProvider()
12 | cssProvider.load_from_path('/usr/local/lib/gbi/ghostbsd-style.css')
13 | screen = Gdk.Screen.get_default()
14 | styleContext = Gtk.StyleContext()
15 | styleContext.add_provider_for_screen(
16 | screen,
17 | cssProvider,
18 | Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
19 | )
20 |
21 |
22 | class AddUsers:
23 |
24 | def save_selection(self):
25 | uname = self.user.get_text()
26 | name = self.name.get_text()
27 | up = self.password.get_text()
28 | shell = self.sh
29 | hf = '/home/%s' % self.user.get_text()
30 | hst = self.host.get_text()
31 | ul = [uname, name, up, shell, hf]
32 |
33 | def on_shell(self, widget):
34 | SHELL = widget.get_active_text()
35 | if SHELL == 'sh':
36 | self.sh = '/bin/sh'
37 | elif SHELL == 'csh':
38 | self.sh = '/bin/csh'
39 | elif SHELL == 'tcsh':
40 | self.sh = '/bin/tcsh'
41 | elif SHELL == 'fish':
42 | self.sh = '/usr/local/bin/fish'
43 | elif SHELL == 'bash':
44 | self.sh = '/usr/local/bin/bash'
45 | elif SHELL == 'rbash':
46 | self.sh = '/usr/local/bin/rbash'
47 | elif SHELL == 'zsh':
48 | self.sh = '/usr/local/bin/zsh'
49 | elif SHELL == 'ksh':
50 | self.sh = '/usr/local/bin/ksh93'
51 |
52 | def userAndHost(self, widget):
53 | username = self.name.get_text().split()
54 | self.host.set_text("%s-ghostbsd-pc" % username[0].lower())
55 | self.user.set_text(username[0].lower())
56 |
57 | def __init__(self, button3):
58 | self.vbox1 = Gtk.VBox(False, 0)
59 | self.vbox1.show()
60 | Title = Gtk.Label("User Setup", name="Header")
61 | Title.set_property("height-request", 50)
62 | self.vbox1.pack_start(Title, False, False, 0)
63 | box2 = Gtk.VBox(False, 0)
64 | box2.set_border_width(10)
65 | self.vbox1.pack_start(box2, False, False, 0)
66 | box2.show()
67 | box2 = Gtk.VBox(False, 10)
68 | # box2.set_border_width(10)
69 | self.vbox1.pack_start(box2, False, False, 0)
70 | box2.show()
71 | label = Gtk.Label('User Account')
72 | label.set_use_markup(True)
73 | label.set_alignment(.2, .2)
74 | Username = Gtk.Label("User name")
75 | self.user = Gtk.Entry()
76 | self.label2 = Gtk.Label("Real name")
77 | self.name = Gtk.Entry()
78 | self.name.connect("changed", self.userAndHost)
79 | self.labelpass = Gtk.Label("Password")
80 | self.password = Gtk.Entry()
81 | self.password.set_visibility(False)
82 | self.password.connect("changed", self.password_verification, button3)
83 | self.label4 = Gtk.Label("Verify Password")
84 | self.repassword = Gtk.Entry()
85 | self.repassword.set_visibility(False)
86 | self.repassword.connect("changed", self.password_verification, button3)
87 | self.label5 = Gtk.Label("Shell")
88 | shell = Gtk.ComboBoxText()
89 | self.sh = '/usr/local/bin/fish'
90 | shell.append_text('sh')
91 | shell.append_text('csh')
92 | shell.append_text('tcsh')
93 | shell.append_text('fish')
94 | shell.append_text('bash')
95 | shell.append_text('rbash')
96 | shell.append_text('ksh')
97 | shell.append_text('zsh')
98 | shell.set_active(3)
99 | shell.connect("changed", self.on_shell)
100 | label = Gtk.Label('Set Hostname')
101 | label.set_use_markup(True)
102 | label.set_alignment(0, .5)
103 | table = Gtk.Table(1, 3, True)
104 | table.set_row_spacings(10)
105 | pcname = Gtk.Label("Hostname")
106 | self.host = Gtk.Entry()
107 | # table.attach(label, 0, 2, 0, 1)
108 | table.attach(self.label2, 0, 1, 1, 2)
109 | table.attach(self.name, 1, 2, 1, 2)
110 | table.attach(pcname, 0, 1, 2, 3)
111 | table.attach(self.host, 1, 2, 2, 3)
112 | table.attach(Username, 0, 1, 3, 4)
113 | table.attach(self.user, 1, 2, 3, 4)
114 | table.attach(self.labelpass, 0, 1, 4, 5)
115 | table.attach(self.password, 1, 2, 4, 5)
116 | self.label3 = Gtk.Label()
117 | table.attach(self.label3, 2, 3, 4, 5)
118 | table.attach(self.label4, 0, 1, 5, 6)
119 | table.attach(self.repassword, 1, 2, 5, 6)
120 | # set image for password matching
121 | self.img = Gtk.Image()
122 | table.attach(self.img, 2, 3, 5, 6)
123 | table.attach(self.label5, 0, 1, 6, 7)
124 | table.attach(shell, 1, 2, 6, 7)
125 | box2.pack_start(table, False, False, 0)
126 | self.box3 = Gtk.VBox(False, 10)
127 | self.box3.set_border_width(10)
128 | self.vbox1.pack_start(self.box3, True, True, 0)
129 | self.box3.show()
130 | # self.label3 = Gtk.Label()
131 | # self.box3.pack_start(self.label3, False, False, 0)
132 |
133 | def get_model(self):
134 | return self.vbox1
135 |
136 | def password_verification(self, widget, button3):
137 | password = self.password.get_text()
138 | password_strength(password, self.label3)
139 | repassword = self.repassword.get_text()
140 | if password == repassword and password != "" and " " not in password:
141 | self.img.set_from_stock(Gtk.STOCK_YES, 5)
142 | button3.set_sensitive(True)
143 | else:
144 | self.img.set_from_stock(Gtk.STOCK_NO, 5)
145 | button3.set_sensitive(False)
146 |
--------------------------------------------------------------------------------
/src/backend-query/detect-laptop.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | dmesgLine=`dmesg | grep "acpi_acad0"`
4 | if test "${dmesgLine}" = ""; then
5 | echo "laptop: NO"
6 | else
7 | echo "laptop: YES"
8 | fi
9 |
--------------------------------------------------------------------------------
/src/backend-query/detect-nics.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | rm /tmp/netCards 2>/dev/null
4 | touch /tmp/netCards
5 |
6 | config="`ifconfig -l`"
7 |
8 | for i in $config
9 | do
10 | echo "${i}" | grep -e "lo0" -e "^fwe" -e "^fwip" -e "lo1" -e "^plip" -e "^pfsync" -e "^pflog" -e "^tun" >/dev/null 2>/dev/null
11 | if [ "$?" != "0" ]
12 | then
13 | IDENT="<`dmesg | grep ^${i} | grep -v "miibus" | grep '<' | cut -d '<' -f 2 | cut -d '>' -f 1 | head -1`>"
14 | echo "${i}: $IDENT"
15 | fi
16 | done
17 |
--------------------------------------------------------------------------------
/src/backend-query/detect-sheme.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Copyright (c) 2009-2012, GhostBSD. All rights reserved.
4 | #
5 | # Redistribution and use in source and binary forms, with or without
6 | # modification, are permitted provided that the following conditions
7 | # are met:
8 | #
9 | # 1. Redistribution's of source code must retain the above copyright
10 | # notice, this list of conditions and the following disclaimer.
11 | #
12 | # 2. Redistribution's in binary form must reproduce the above
13 | # copyright notice,this list of conditions and the following
14 | # disclaimer in the documentation and/or other materials provided
15 | # with the distribution.
16 | #
17 | # 3. Neither then name of GhostBSD Project nor the names of its
18 | # contributors maybe used to endorse or promote products derived
19 | # from this software without specific prior written permission.
20 | #
21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,
27 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | # POSSIBILITY OF SUCH DAMAGE.
33 | #
34 | # /usr/local/etc/gbi/detect-sheme.sh v 0.1 Wed May 1 20:31:52 ADT 2013 Eric Turgeon
35 | #
36 | # Detect a disk sheme and display them.
37 | #
38 |
39 |
40 | DISK="${1}"
41 | TMPDIR=${TMPDIR:-"/tmp"}
42 | # Display if this is GPT or MBR formatted
43 | gpart show ${1} | grep "GPT" >/dev/null 2>/dev/null
44 | if [ "$?" = "0" ] ; then
45 | #echo "${1}-format: GPT"
46 | TYPE="GPT"
47 | else
48 | #echo "${1}-format: MBR"
49 | TYPE="MBR"
50 | fi
51 |
52 | echo ${TYPE}
53 |
--------------------------------------------------------------------------------
/src/backend-query/detect-vmware.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 |
4 | pciconf -lv | grep -i vmware >/dev/null 2>/dev/null
5 | if [ "$?" = "0" ]
6 | then
7 | echo "vmware: YES"
8 | exit 0
9 | else
10 | echo "vmware: NO"
11 | exit 1
12 | fi
13 |
--------------------------------------------------------------------------------
/src/backend-query/detect-wifi.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | NIC="$1"
3 | ifconfig ${NIC} | grep -q "802.11" 2>/dev/null
4 | if [ $? -eq 0 ]; then
5 | echo 'yes'
6 | else
7 | echo 'no'
8 | fi
9 |
--------------------------------------------------------------------------------
/src/backend-query/disk-info.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Query a disk for partitions and display them
3 | #############################
4 |
5 |
6 | if [ -z "${1}" ]
7 | then
8 | echo "Error: No disk specified!"
9 | exit 1
10 | fi
11 |
12 | if [ ! -e "/dev/${1}" ]
13 | then
14 | echo "Error: Disk /dev/${1} does not exist!"
15 | exit 1
16 | fi
17 |
18 | # Function to convert bytes to megabytes
19 | convert_byte_to_megabyte()
20 | {
21 | if [ -z "${1}" ]
22 | then
23 | echo "Error: No bytes specified!"
24 | exit 1
25 | fi
26 |
27 | expr -e ${1} / 1048576
28 | };
29 |
30 | # Function which returns a target disks cylinders
31 | get_disk_cyl()
32 | {
33 | cyl=`diskinfo -v ${1} | grep "# Cylinders" | tr -s ' ' | cut -f 2`
34 | export VAL="${cyl}"
35 | };
36 | DISK="${1}"
37 |
38 | # Function which returns a target disks heads
39 | get_disk_heads()
40 | {
41 | head=`diskinfo -v ${1} | grep "# Heads" | tr -s ' ' | cut -f 2`
42 | export VAL="${head}"
43 | };
44 |
45 | # Function which returns a target disks sectors
46 | get_disk_sectors()
47 | {
48 | sec=`diskinfo -v ${1} | grep "# Sectors" | tr -s ' ' | cut -f 2`
49 | export VAL="${sec}"
50 | };
51 |
52 | get_disk_cyl "${DISK}"
53 | CYLS="${VAL}"
54 |
55 | get_disk_heads "${DISK}"
56 | HEADS="${VAL}"
57 |
58 | get_disk_sectors "${DISK}"
59 | SECS="${VAL}"
60 |
61 | #echo "cylinders=${CYLS}"
62 | #echo "heads=${HEADS}"
63 | #echo "sectors=${SECS}"
64 |
65 | # Now get the disks size in MB
66 | KB="`diskinfo -v ${1} | grep 'bytes' | cut -d '#' -f 1 | tr -s '\t' ' ' | tr -d ' '`"
67 | MB=$(convert_byte_to_megabyte ${KB})
68 | #echo "size=$MB"
69 | echo "$MB"
70 | # Now get the Controller Type
71 | CTYPE="`dmesg | grep "^${1}:" | grep "B <" | cut -d '>' -f 2 | cut -d ' ' -f 3-10`"
72 | #echo "type=$CTYPE"
73 |
--------------------------------------------------------------------------------
/src/backend-query/disk-label.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Query a disk for partitions and display them
3 | #############################
4 |
5 |
6 | DISK="${1}"
7 | TMPDIR=${TMPDIR:-"/tmp"}
8 | # Display if this is GPT or MBR formatted
9 | gpart show ${1} | grep "GPT" >/dev/null 2>/dev/null
10 | if [ "$?" = "0" ] ; then
11 | #echo "${1}-format: GPT"
12 | TYPE="GPT"
13 | else
14 | #echo "${1}-format: MBR"
15 | TYPE="MBR"
16 | fi
17 |
18 | if [ "$TYPE" = "MBR" ] ; then
19 | sp="s"
20 | else
21 | sp="p"
22 | fi
23 |
24 | # Get a listing of partitions on this disk
25 | gpart show ${DISK} | grep -v ${DISK} | tr -s '\t' ' ' | cut -d ' ' -f 4,3,5 >${TMPDIR}/disk-${DISK}
26 | while read i
27 | do
28 |
29 | if [ ! -z "${i}" ] ; then
30 | BLOCK="`echo ${i} | cut -d ' ' -f 1`"
31 | MB="`expr ${BLOCK} / 2048`MB"
32 | fi
33 | if [ ! "${MB}" = "0MB" ] ; then
34 | FS="`echo ${i} | cut -d ' ' -f 3`"
35 | SLICE="`echo ${i} | cut -d ' ' -f 2`"
36 | if [ "$SLICE" = '-' ] ; then
37 | echo "${MB} freespace none"
38 | else
39 | if [ ! -z "$SLICE" ] ; then
40 | echo "${MB} ${SLICE} ${FS}"
41 | fi
42 | fi
43 | fi
44 |
45 | done <${TMPDIR}/disk-${DISK}
46 |
--------------------------------------------------------------------------------
/src/backend-query/disk-list.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Create our device listing
4 | SYSDISK=$(sysctl -n kern.disks)
5 |
6 | # Now loop through these devices, and list the disk drives
7 | for i in ${SYSDISK}
8 | do
9 |
10 | # Get the current device
11 | DEV="${i}"
12 |
13 | # Make sure we don't find any cd devices
14 | case "${DEV}" in
15 | acd[0-9]*|cd[0-9]*|scd[0-9]*) continue ;;
16 | esac
17 |
18 | # Check the dmesg output for some more info about this device
19 | NEWLINE=$(dmesg | sed -n "s/^$DEV: .*<\(.*\)>.*$/ <\1>/p" | head -n 1)
20 | if [ -z "$NEWLINE" ]; then
21 | NEWLINE=" "
22 | fi
23 |
24 | # Save the disk list
25 | if [ ! -z "$DLIST" ]
26 | then
27 | DLIST="\n${DLIST}"
28 | fi
29 |
30 | DLIST="${DEV} ${NEWLINE}${DLIST}"
31 |
32 | done
33 |
34 | # Echo out the found line
35 | echo -e "$DLIST" | sort
36 |
--------------------------------------------------------------------------------
/src/backend-query/disk-part.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Query a disk for partitions and display them
3 | #############################
4 |
5 |
6 | DISK="${1}"
7 | TMPDIR=${TMPDIR:-"/tmp"}
8 | # Display if this is GPT or MBR formatted
9 | gpart show ${DISK} | grep "GPT" >/dev/null 2>/dev/null
10 | if [ "$?" = "0" ] ; then
11 | #echo "${1}-format: GPT"
12 | TYPE="GPT"
13 | else
14 | #echo "${1}-format: MBR"
15 | TYPE="MBR"
16 | fi
17 |
18 | if [ "$TYPE" = "MBR" ] ; then
19 | sp="s"
20 | else
21 | sp="p"
22 | fi
23 |
24 | # Get a listing of partitions on this disk
25 | gpart show ${DISK} | grep -v ${DISK} | tr -s '\t' ' ' | cut -d ' ' -f 4,3,5 >${TMPDIR}/disk-${DISK}
26 | while read i
27 | do
28 | if [ ! -z "${i}" ] ; then
29 | BLOCK="`echo ${i} | cut -d ' ' -f 1`"
30 | if [ "${BLOCK}" -ge 2048 ] ; then
31 | MB="`expr ${BLOCK} / 2048`"
32 | else
33 | MB="1"
34 | fi
35 | fi
36 | if [ ! "${MB}" = "0" ] ; then
37 | LABEL="`echo ${i} | cut -d ' ' -f 3`"
38 | SLICE="`echo ${i} | cut -d ' ' -f 2`"
39 | if [ "$SLICE" = '-' ] ; then
40 | if [ ! "${MB}" = "1" ] ; then
41 | echo "freespace ${MB} none"
42 | fi
43 | else
44 | if [ ! -z "$SLICE" ] ; then
45 | echo "${DISK}${sp}${SLICE} ${MB} ${LABEL} "
46 | fi
47 | fi
48 | fi
49 | done <${TMPDIR}/disk-${DISK}
50 |
--------------------------------------------------------------------------------
/src/backend-query/enable-net.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Script which enables networking with specified options
3 | ###########################################################################
4 |
5 | . ${PROGDIR}/backend/functions.sh
6 | . ${PROGDIR}/conf/pc-sysinstall.conf
7 | . ${BACKEND}/functions-networking.sh
8 | . ${BACKEND}/functions-parse.sh
9 |
10 |
11 | NIC="$1"
12 | IP="$2"
13 | NETMASK="$3"
14 | DNS="$4"
15 | GATEWAY="$5"
16 | MIRRORFETCH="$6"
17 |
18 | if [ -z "${NIC}" ]
19 | then
20 | echo "ERROR: Usage enable-net "
21 | exit 150
22 | fi
23 |
24 | if [ "$NIC" = "AUTO-DHCP" ]
25 | then
26 | enable_auto_dhcp
27 | else
28 | echo "Enabling NIC: $NIC"
29 | ifconfig ${NIC} ${IP} ${NETMASK}
30 |
31 | echo "nameserver ${DNS}" >/etc/resolv.conf
32 |
33 | route add default ${GATE}
34 | fi
35 |
36 | case ${MIRRORFETCH} in
37 | ON|on|yes|YES) fetch -o /tmp/mirrors-list.txt ${MIRRORLIST} >/dev/null 2>/dev/null;;
38 | *) ;;
39 | esac
40 |
--------------------------------------------------------------------------------
/src/backend-query/list-components.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Script which lists the available components for this release
3 | ###########################################################################
4 |
5 | . ${PROGDIR}/backend/functions.sh
6 |
7 | echo "Available Components:"
8 |
9 | cd ${COMPDIR}
10 | for i in `ls -d *`
11 | do
12 | if [ -e "${i}/component.cfg" -a -e "${i}/install.sh" -a -e "${i}/distfiles" ]
13 | then
14 | NAME="`grep 'name:' ${i}/component.cfg | cut -d ':' -f 2`"
15 | DESC="`grep 'description:' ${i}/component.cfg | cut -d ':' -f 2`"
16 | TYPE="`grep 'type:' ${i}/component.cfg | cut -d ':' -f 2`"
17 | echo " "
18 | echo "name: ${i}"
19 | echo "desc:${DESC}"
20 | echo "type:${TYPE}"
21 | if [ -e "${i}/component.png" ]
22 | then
23 | echo "icon: ${COMPDIR}/${i}/component.png"
24 | fi
25 | fi
26 |
27 | done
28 |
29 |
--------------------------------------------------------------------------------
/src/backend-query/list-rsync-backups.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Script which lists the backups present on a server
3 | ###########################################################################
4 |
5 | . ${PROGDIR}/backend/functions.sh
6 |
7 | SSHUSER=$1
8 | SSHHOST=$2
9 | SSHPORT=$3
10 |
11 | if [ -z "${SSHHOST}" -o -z "${SSHPORT}" ]
12 | then
13 | echo "ERROR: Usage list-rsync-backups.sh "
14 | exit 150
15 | fi
16 |
17 | # Look for full-system backups, needs at minimum a kernel to be bootable
18 | FINDCMD="find . -type d -maxdepth 6 -name 'kernel' | grep '/boot/kernel'"
19 |
20 | # Get a listing of the number of full backups saved
21 | OLDBACKUPS=`ssh -o 'BatchMode=yes' -p ${SSHPORT} ${SSHUSER}@${SSHHOST} "${FINDCMD}"`
22 | if [ "$?" = "0" ]
23 | then
24 | for i in ${OLDBACKUPS}
25 | do
26 | BACKPATH="`echo ${i} | sed 's|/boot/.*||g' | sed 's|^./||g'`"
27 | if [ -z "${BACKLIST}" ]
28 | then
29 | BACKLIST="${BACKPATH}"
30 | else
31 | BACKLIST="${BACKLIST}:${BACKPATH}"
32 | fi
33 | done
34 |
35 | if [ -z "${BACKLIST}" ]
36 | then
37 | echo "NONE"
38 | else
39 | echo "$BACKLIST"
40 | fi
41 |
42 | else
43 | echo "FAILED"
44 | fi
45 |
--------------------------------------------------------------------------------
/src/backend-query/list-tzones.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | rm ${TMPDIR}/.tzonetmp >/dev/null 2>/dev/null
4 |
5 | # Backend script which lists all the available timezones for front-ends to display
6 | while read line
7 | do
8 | echo "$line" | grep "^#" >/dev/null 2>/dev/null
9 | if [ "$?" != "0" ]
10 | then
11 | echo "$line" | tr -s "\t" ":" | cut -d ":" -f 3-4 >>${TMPDIR}/.tzonetmp
12 | fi
13 | done < /usr/share/zoneinfo/zone.tab
14 |
15 | sort ${TMPDIR}/.tzonetmp
16 | rm -f ${TMPDIR}/.tzonetmp >/dev/null 2>/dev/null
17 |
18 | exit 0
19 |
--------------------------------------------------------------------------------
/src/backend-query/query-langs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | FOUND="0"
4 |
5 | cat ${PROGDIR}/conf/avail-langs
6 |
7 | exit 0
8 |
--------------------------------------------------------------------------------
/src/backend-query/send-logs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Script which creates a gzipped log and optionally mails it to the specified address
3 | ############################################################################
4 |
5 | . ${PROGDIR}/backend/functions.sh
6 | . ${PROGDIR}/conf/pc-sysinstall.conf
7 | . ${BACKEND}/functions-networking.sh
8 | . ${BACKEND}/functions-parse.sh
9 |
10 | # Bring up all NICS under DHCP
11 | enable_auto_dhcp
12 |
13 | MAILTO="$1"
14 | MAILRESULT="0"
15 |
16 | # Set the location of our compressed log
17 | TMPLOG="/tmp/pc-sysinstall.log"
18 |
19 | echo "# PC-SYSINSTALL LOG" >${TMPLOG}
20 | cat ${LOGOUT} >> ${TMPLOG}
21 |
22 | # Check if we have a GUI generated install cfg
23 | if [ -e "/tmp/sys-install.cfg" ]
24 | then
25 | echo "" >>${TMPLOG}
26 | echo "# PC-SYSINSTALL CFG " >>${TMPLOG}
27 | cat /tmp/sys-install.cfg >> ${TMPLOG}
28 | fi
29 |
30 | # Save dmesg output
31 | echo "" >>${TMPLOG}
32 | echo "# DMESG OUTPUT " >>${TMPLOG}
33 | dmesg >> ${TMPLOG}
34 |
35 | # Get gpart info on all disks
36 | for i in `${PROGDIR}/pc-sysinstall disk-list | cut -d ':' -f 1`
37 | do
38 | echo "" >>${TMPLOG}
39 | echo "# DISK INFO $i " >>${TMPLOG}
40 | ls /dev/${i}* >>${TMPLOG}
41 | gpart show ${i} >> ${TMPLOG}
42 | done
43 |
44 | # Show Mounted volumes
45 | echo "" >>${TMPLOG}
46 | echo "# MOUNT OUTPUT " >>${TMPLOG}
47 | mount >> ${TMPLOG}
48 |
49 | echo "Log file saved to ${TMPLOG}"
50 | echo "Warning: This file will be lost once the system is rebooted."
51 |
52 | echo "Do you wish to view this logfile now? (Y/N)"
53 | read tmp
54 | if [ "$tmp" = "Y" -o "$tmp" = "y" ]
55 | then
56 | more ${TMPLOG}
57 | fi
58 |
--------------------------------------------------------------------------------
/src/backend-query/setup-ssh-keys.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Script which sets up password-less logins for ssh host
3 | ###########################################################################
4 |
5 | . ${PROGDIR}/backend/functions.sh
6 |
7 | SSHUSER=$1
8 | SSHHOST=$2
9 | SSHPORT=$3
10 |
11 | if [ -z "${SSHUSER}" -o -z "${SSHHOST}" -o -z "${SSHPORT}" ]
12 | then
13 | echo "ERROR: Usage setup-ssh-keys "
14 | exit 150
15 | fi
16 |
17 | cd ~
18 |
19 | echo "Preparing to setup SSH key authorization..."
20 | echo "When prompted, enter your password for ${SSHUSER}@${SSHHOST}"
21 |
22 | if [ ! -e ".ssh/id_rsa.pub" ]
23 | then
24 | mkdir .ssh >/dev/null 2>/dev/null
25 | ssh-keygen -q -t rsa -N '' -f .ssh/id_rsa
26 | sleep 1
27 | fi
28 |
29 | if [ ! -e ".ssh/id_rsa.pub" ]
30 | then
31 | echo "ERROR: Failed creating .ssh/id_rsa.pub"
32 | exit 150
33 | fi
34 |
35 | # Get the .pub key
36 | PUBKEY="`cat .ssh/id_rsa.pub`"
37 |
38 | ssh -p ${SSHPORT} ${SSHUSER}@${SSHHOST} "mkdir .ssh ; echo $PUBKEY >> .ssh/authorized_keys; chmod 600 .ssh/authorized_keys ; echo $PUBKEY >> .ssh/authorized_keys2; chmod 600 .ssh/authorized_keys2"
39 |
--------------------------------------------------------------------------------
/src/backend-query/sys-mem.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | MEM=`sysctl hw.realmem | sed "s|hw.realmem: ||g"`
4 | MEM=`expr $MEM / 1024`
5 | MEM=`expr $MEM / 1024`
6 | echo $MEM
7 |
--------------------------------------------------------------------------------
/src/backend-query/test-live.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Script which checks if we are running from install media, or real system
3 | #############################################################################
4 |
5 | dmesg | grep "md0: Preloaded image" >/dev/null 2>/dev/null
6 | if [ "$?" = "0" ]
7 | then
8 | echo "INSTALL-MEDIA"
9 | exit 0
10 | else
11 | echo "REAL-DISK"
12 | exit 1
13 | fi
14 |
15 |
--------------------------------------------------------------------------------
/src/backend-query/test-netup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Script which tests "fetch" when using a network connection, and saves
3 | # if we are using direct connect, or need FTP passive mode
4 | #############################################################################
5 |
6 | rm ${TMPDIR}/.testftp >/dev/null 2>/dev/null
7 |
8 | ping -c 2 www.pcbsd.org >/dev/null 2>/dev/null
9 | if [ "$?" = "0" ]
10 | then
11 | echo "ftp: Up"
12 | exit 0
13 | fi
14 |
15 | ping -c 2 www.freebsd.org >/dev/null 2>/dev/null
16 | if [ "$?" = "0" ]
17 | then
18 | echo "ftp: Up"
19 | exit 0
20 | fi
21 |
22 | echo "ftp: Down"
23 | exit 1
24 |
--------------------------------------------------------------------------------
/src/backend-query/update-part-list.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Need access to a some unmount functions
4 | . ${PROGDIR}/backend/functions-unmount.sh
5 |
6 | echo "Running: find-update-parts" >> ${LOGOUT}
7 |
8 | rm ${TMPDIR}/AvailUpgrades >/dev/null 2>/dev/null
9 |
10 | FSMNT="/mnt"
11 |
12 | # Get the freebsd version on this partition
13 | get_fbsd_ver() {
14 |
15 | VER="`file ${FSMNT}/bin/sh | grep 'for FreeBSD' | sed 's|for FreeBSD |;|g' | cut -d ';' -f 2 | cut -d ',' -f 1`"
16 | if [ "$?" = "0" ] ; then
17 | file ${FSMNT}/bin/sh | grep '32-bit' >/dev/null 2>/dev/null
18 | if [ "${?}" = "0" ] ; then
19 | echo "${1}: FreeBSD ${VER} (32bit)"
20 | else
21 | echo "${1}: FreeBSD ${VER} (64bit)"
22 | fi
23 | fi
24 |
25 | }
26 |
27 | # Create our device listing
28 | SYSDISK="`sysctl kern.disks | cut -d ':' -f 2 | sed 's/^[ \t]*//'`"
29 | DEVS=""
30 |
31 | # Now loop through these devices, and list the disk drives
32 | for i in ${SYSDISK}
33 | do
34 |
35 | # Get the current device
36 | DEV="${i}"
37 | # Make sure we don't find any cd devices
38 | echo "${DEV}" | grep -e "^acd[0-9]" -e "^cd[0-9]" -e "^scd[0-9]" >/dev/null 2>/dev/null
39 | if [ "$?" != "0" ] ; then
40 | DEVS="${DEVS} `ls /dev/${i}*`"
41 | fi
42 |
43 | done
44 |
45 | # Search for regular UFS / Geom Partitions to upgrade
46 | for i in $DEVS
47 | do
48 | if [ ! -e "${i}a.journal" -a ! -e "${i}a" -a ! -e "${i}p2" -a ! -e "${i}p2.journal" ] ; then
49 | continue
50 | fi
51 |
52 | if [ -e "${i}a.journal" ] ; then
53 | _dsk="${i}a.journal"
54 | elif [ -e "${i}a" ] ; then
55 | _dsk="${i}a"
56 | elif [ -e "${i}p2" ] ; then
57 | _dsk="${i}p2"
58 | elif [ -e "${i}p2.journal" ] ; then
59 | _dsk="${i}p2.journal"
60 | fi
61 |
62 | mount ${_dsk} ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
63 | if [ "${?}" = "0" -a -e "${FSMNT}/bin/sh" ] ; then
64 | get_fbsd_ver "`echo ${_dsk} | sed 's|/dev/||g'`"
65 | umount -f ${FSMNT} >/dev/null 2>/dev/null
66 | fi
67 | done
68 |
69 | # Now search for any ZFS root partitions
70 | zpool import -o altroot=${FSMNT} -a
71 |
72 | # Unmount any auto-mounted stuff
73 | umount_all_dir "${FSMNT}"
74 |
75 | # Get pools
76 | _zps="`zpool list | grep -v 'NAME' | cut -d ' ' -f 1`"
77 | for _zpools in ${_zps}
78 | do
79 | mount -t zfs ${_zpools} ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
80 | if [ "${?}" = "0" -a -e "${FSMNT}/bin/sh" ] ; then
81 | get_fbsd_ver "${_zpools}"
82 | umount -f ${FSMNT} >/dev/null 2>/dev/null
83 | fi
84 | done
85 |
--------------------------------------------------------------------------------
/src/backend-query/xkeyboard-layouts.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | FOUND="0"
4 |
5 | # Lets parse the xorg.list file, and see what layouts are supported
6 | while read line
7 | do
8 |
9 | if [ "$FOUND" = "1" -a ! -z "$line" ]
10 | then
11 | echo $line | grep '! ' >/dev/null 2>/dev/null
12 | if [ "$?" = "0" ]
13 | then
14 | exit 0
15 | else
16 | echo "$line"
17 | fi
18 | fi
19 |
20 | if [ "${FOUND}" = "0" ]
21 | then
22 | echo $line | grep '! layout' >/dev/null 2>/dev/null
23 | if [ "$?" = "0" ]
24 | then
25 | FOUND="1"
26 | fi
27 | fi
28 |
29 | done < /usr/local/share/X11/xkb/rules/xorg.lst
30 |
31 | exit 0
32 |
--------------------------------------------------------------------------------
/src/backend-query/xkeyboard-models.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | FOUND="0"
4 |
5 | # Lets parse the xorg.list file, and see what models are supported
6 | while read line
7 | do
8 |
9 | if [ "$FOUND" = "1" -a ! -z "$line" ]
10 | then
11 | echo $line | grep '! ' >/dev/null 2>/dev/null
12 | if [ "$?" = "0" ]
13 | then
14 | exit 0
15 | else
16 | model="`echo $line | sed 's|(|[|g'`"
17 | model="`echo $model | sed 's|)|]|g'`"
18 | echo "$model"
19 | fi
20 | fi
21 |
22 | if [ "${FOUND}" = "0" ]
23 | then
24 | echo $line | grep '! model' >/dev/null 2>/dev/null
25 | if [ "$?" = "0" ]
26 | then
27 | FOUND="1"
28 | fi
29 | fi
30 |
31 | done < /usr/local/share/X11/xkb/rules/xorg.lst
32 |
33 | exit 0
34 |
--------------------------------------------------------------------------------
/src/backend-query/xkeyboard-variants.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | FOUND="0"
4 |
5 | # Lets parse the xorg.list file, and see what varients are supported
6 | while read line
7 | do
8 |
9 | if [ "$FOUND" = "1" -a ! -z "$line" ]
10 | then
11 | echo $line | grep '! ' >/dev/null 2>/dev/null
12 | if [ "$?" = "0" ]
13 | then
14 | exit 0
15 | else
16 | echo "$line"
17 | fi
18 | fi
19 |
20 | if [ "${FOUND}" = "0" ]
21 | then
22 | echo $line | grep '! variant' >/dev/null 2>/dev/null
23 | if [ "$?" = "0" ]
24 | then
25 | FOUND="1"
26 | fi
27 | fi
28 |
29 | done < /usr/local/share/X11/xkb/rules/xorg.lst
30 |
31 | exit 0
32 |
--------------------------------------------------------------------------------
/src/boot_manager.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright (c) 2019 GhostBSD
4 |
5 | import gi
6 | gi.require_version('Gtk', '3.0')
7 | from gi.repository import Gtk, Gdk
8 | import os
9 | import os.path
10 | from partition_handler import bios_or_uefi
11 |
12 |
13 | # Folder use pr the installer.
14 | tmp = "/tmp/.gbi"
15 | installer = "/usr/local/lib/gbi/"
16 | query = "sh /usr/local/etc/lib/backend-query/"
17 | if not os.path.exists(tmp):
18 | os.makedirs(tmp)
19 |
20 |
21 | boot_file = f'{tmp}/boot'
22 | disk_scheme = f'{tmp}/scheme'
23 | zfs_config = f'{tmp}/zfs_config'
24 | ufs_config = f'{tmp}/ufs_config'
25 |
26 | cssProvider = Gtk.CssProvider()
27 | cssProvider.load_from_path('/usr/local/lib/gbi/ghostbsd-style.css')
28 | screen = Gdk.Screen.get_default()
29 | styleContext = Gtk.StyleContext()
30 | styleContext.add_provider_for_screen(
31 | screen,
32 | cssProvider,
33 | Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
34 | )
35 |
36 |
37 | class bootManager():
38 |
39 | def get_model(self):
40 | return self.vbox1
41 |
42 | def boot_manager(self, radiobutton, val):
43 | self.boot = val
44 | boot = open(boot_file, 'w')
45 | boot.writelines(self.boot)
46 | boot.close()
47 |
48 | def __init__(self):
49 | self.vbox1 = Gtk.VBox(False, 0)
50 | self.vbox1.show()
51 | if bios_or_uefi() == "UEFI":
52 | loader = "UEFI"
53 | else:
54 | loader = "BIOS"
55 | if os.path.exists(zfs_config):
56 | # Disk Setup
57 | read = open(zfs_config, 'r')
58 | read_scheme = read.read()
59 | elif os.path.exists(ufs_config):
60 | # Disk Setup
61 | read = open(ufs_config, 'r')
62 | read_scheme = read.read()
63 | else:
64 | # Scheme file
65 | read = open(disk_scheme, 'r')
66 | read_scheme = read.read()
67 | scheme = 'GPT' if 'GPT' in read_scheme else 'MBR'
68 | Title = Gtk.Label('Boot Option', name="Header")
69 | Title.set_property("height-request", 50)
70 | self.vbox1.pack_start(Title, False, False, 0)
71 | hbox1 = Gtk.HBox()
72 | hbox1.show()
73 | self.vbox1.pack_start(hbox1, True, True, 10)
74 | bbox1 = Gtk.VBox()
75 | bbox1.show()
76 | self.refind = Gtk.RadioButton().new_with_label_from_widget(
77 | None,
78 | "Setup rEFInd boot manager"
79 | )
80 | bbox1.pack_start(self.refind, False, True, 10)
81 | self.refind.connect("toggled", self.boot_manager, "refind")
82 | self.refind.show()
83 | if scheme == 'GPT' and loader == "UEFI":
84 | self.refind.set_sensitive(True)
85 | else:
86 | self.refind.set_sensitive(False)
87 | self.bsd = Gtk.RadioButton.new_with_label_from_widget(
88 | self.refind,
89 | "Setup FreeBSD boot manager"
90 | )
91 | bbox1.pack_start(self.bsd, False, True, 10)
92 | self.bsd.connect("toggled", self.boot_manager, "bsd")
93 | self.bsd.show()
94 | if scheme == 'MBR':
95 | self.bsd.set_sensitive(True)
96 | else:
97 | self.bsd.set_sensitive(False)
98 | self.none = Gtk.RadioButton.new_with_label_from_widget(
99 | self.bsd,
100 | f"FreeBSD {loader} loader only"
101 | )
102 | bbox1.pack_start(self.none, False, True, 10)
103 | self.none.connect("toggled", self.boot_manager, "none")
104 | self.none.show()
105 | hbox1.pack_start(bbox1, False, False, 50)
106 | self.none.set_active(True)
107 | self.boot = "none"
108 | boot = open(boot_file, 'w')
109 | boot.writelines(self.boot)
110 | boot.close()
111 | self.box3 = Gtk.VBox(False, 0)
112 | self.box3.set_border_width(0)
113 | self.vbox1.pack_start(self.box3, True, True, 0)
114 | return
115 |
--------------------------------------------------------------------------------
/src/create_cfg.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | import os
4 | import pickle
5 |
6 | # Directory use from the installer.
7 | tmp = "/tmp/.gbi"
8 | installer = "/usr/local/lib/gbi/"
9 | # Installer data file.
10 | disk = f'{tmp}/disk'
11 | pcinstallcfg = f'{tmp}/pcinstall.cfg'
12 | user_passwd = f'{tmp}/user_admin'
13 | language = f'{tmp}/language'
14 | dslice = f'{tmp}/slice'
15 | left = f'{tmp}/left'
16 | partlabel = f'{tmp}/partlabel'
17 | timezone = f'{tmp}/timezone'
18 | KBFile = f'{tmp}/keyboard'
19 | boot_file = f'{tmp}/boot'
20 | disk_scheme = f'{tmp}/scheme'
21 | zfs_config = f'{tmp}/zfs_config'
22 | ufs_config = f'{tmp}/ufs_config'
23 |
24 |
25 | class GhostBSDCfg:
26 | def __init__(self):
27 | f = open(f'{tmp}/pcinstall.cfg', 'w')
28 | # Installation Mode
29 | f.write('# Installation Mode\n')
30 | f.write('installMode=fresh\n')
31 | f.write('installInteractive=no\n')
32 | f.write('installType=GhostBSD\n')
33 | f.write('installMedium=livezfs\n')
34 | f.write('packageType=livezfs\n')
35 | # System Language
36 | if os.path.exists(language):
37 | langfile = open(language, 'r')
38 | lang = langfile.readlines()[0].rstrip()
39 | f.write('\n# System Language\n')
40 | f.write(f'localizeLang={lang}\n')
41 | # Keyboard Setting
42 | if os.path.exists(KBFile):
43 | f.write('\n# Keyboard Setting\n')
44 | rkb = open(KBFile, 'r')
45 | kb = rkb.readlines()
46 | kbl = kb[0].rstrip()
47 | f.write(f'localizeKeyLayout={kbl}\n')
48 | kbv = kb[1].rstrip()
49 | if kbv != 'None':
50 | f.write(f'localizeKeyVariant={kbv}\n')
51 | kbm = kb[2].rstrip()
52 | if kbm != 'None':
53 | f.write(f'localizeKeyModel={kbm}\n')
54 | # Timezone
55 | if os.path.exists(timezone):
56 | time = open(timezone, 'r')
57 | t_output = time.readlines()[0].strip()
58 | f.write('\n# Timezone\n')
59 | f.write(f'timeZone={t_output}\n')
60 | f.write('enableNTP=yes\n')
61 | if os.path.exists(zfs_config):
62 | zfs = True
63 | # Disk Setup
64 | r = open(zfs_config, 'r')
65 | zfsconf = r.readlines()
66 | for line in zfsconf:
67 | if 'partscheme' in line:
68 | f.write(line)
69 | read = open(boot_file, 'r')
70 | boot = read.readlines()[0].strip()
71 | if boot == 'refind':
72 | f.write('bootManager=none\n')
73 | f.write(f'efiLoader={boot}\n')
74 | else:
75 | f.write(f'bootManager={boot}\n')
76 | f.write('efiLoader=none\n')
77 | else:
78 | f.write(line)
79 | elif os.path.exists(ufs_config):
80 | zfs = False
81 | # Disk Setup
82 | r = open(ufs_config, 'r')
83 | ufsconf = r.readlines()
84 | for line in ufsconf:
85 | if 'partscheme' in line:
86 | f.write(line)
87 | read = open(boot_file, 'r')
88 | boot = read.readlines()[0].strip()
89 | if boot == 'refind':
90 | f.write('bootManager=none\n')
91 | f.write(f'efiLoader={boot}\n')
92 | else:
93 | f.write(f'bootManager={boot}\n')
94 | f.write('efiLoader=none\n')
95 | else:
96 | f.write(line)
97 | else:
98 | # Disk Setup
99 | r = open(disk, 'r')
100 | drive = r.readlines()
101 | d_output = drive[0].strip()
102 | f.write('\n# Disk Setup\n')
103 | f.write('ashift=12\n')
104 | f.write(f'disk0={d_output}\n')
105 | # Partition Slice.
106 | p = open(dslice, 'r')
107 | line = p.readlines()
108 | part = line[0].rstrip()
109 | f.write(f'partition={part}\n')
110 | # Boot Menu
111 | read = open(boot_file, 'r')
112 | line = read.readlines()
113 | boot = line[0].strip()
114 | if boot == 'refind':
115 | f.write('bootManager=none\n')
116 | f.write(f'efiLoader={boot}\n')
117 | else:
118 | f.write(f'bootManager={boot}\n')
119 | f.write('efiLoader=none\n')
120 | # Scheme
121 | read = open(disk_scheme, 'r')
122 | scheme = read.readlines()[0]
123 | f.write(f'{scheme}\n')
124 | f.write('commitDiskPart\n')
125 | # Partition Setup
126 | f.write('\n# Partition Setup\n')
127 | part = open(partlabel, 'r').read()
128 | zfs = True if 'ZFS' in part else False
129 | # If slice and auto file exist add first partition line.
130 | # But Swap need to be 0 it will take the rest of the freespace.
131 | for line in part.splitlines():
132 | if 'BOOT' in line or 'BIOS' in line or 'UEFI' in line:
133 | pass
134 | else:
135 | f.write(f'disk0-part={line.strip()}\n')
136 | f.write('commitDiskLabel\n')
137 | if os.path.exists(user_passwd):
138 | # Network Configuration
139 | f.write('\n# Network Configuration\n')
140 | readu = open(user_passwd, 'rb')
141 | uf = pickle.load(readu)
142 | hostname = uf[5]
143 | f.write(f'hostname={hostname}\n')
144 | # Set the root pass
145 | f.write('\n# Root Password\n')
146 | readr = open(f'{tmp}/root', 'rb')
147 | rf = pickle.load(readr)
148 | root = rf[0]
149 | f.write(f'rootPass={root}\n')
150 | # Setup our users
151 | user = uf[0]
152 | f.write('\n# Setup user\n')
153 | f.write(f'userName={user}\n')
154 | name = uf[1]
155 | f.write(f'userComment={name}\n')
156 | passwd = uf[2]
157 | f.write(f'userPass={passwd.rstrip()}\n')
158 | shell = uf[3]
159 | f.write(f'userShell={shell}\n')
160 | upath = uf[4]
161 | f.write(f'userHome={upath.rstrip()}\n')
162 | f.write('userGroups=wheel,operator\n')
163 | f.write('commitUser\n')
164 | f.write('\n# Run command and script\n')
165 | f.write("""runCommand=sed -i '' 's/lightdm_enable="NO"/"""
166 | """lightdm_enable="YES"/g' /etc/rc.conf\n""")
167 | f.write('runCommand=sed -i "" "/ghostbsd/d" /etc/gettytab\n')
168 | f.write(
169 | 'runCommand=sed -i "" "/ttyv0/s/ghostbsd/Pc/g" /etc/ttys\n')
170 |
171 | f.write("runCommand=mv /usr/local/etc/devd/automount_devd"
172 | ".conf.skip /usr/local/etc/devd/automount_devd.conf\n")
173 | f.write("runCommand=mv /usr/local/etc/devd/automount_devd"
174 | "_localdisks.conf.skip /usr/local/etc/devd/"
175 | "automount_devd_localdisks.conf\n")
176 | if zfs is True:
177 | zfsark = "echo 'vfs.zfs.arc_max=\"512M\"' >> /boot/loader.conf"
178 | f.write(f'runCommand={zfsark}\n')
179 | else:
180 | f.write('\n# Network Configuration\n')
181 | f.write('hostname=installed\n')
182 | f.write('\n# command to prepare first boot\n')
183 | f.write("runCommand=sysrc hostname='installed'\n")
184 | f.write("runCommand=pw userdel -n ghostbsd -r\n")
185 | f.write("runCommand=sed -i '' 's/ghostbsd/root/g' /etc/gettytab\n")
186 | f.write("runCommand=sed -i '' 's/ghostbsd/root/g' /etc/ttys\n")
187 | f.write("runCommand=mv /usr/local/etc/devd/automount_devd"
188 | ".conf.skip /usr/local/etc/devd/automount_devd.conf\n")
189 | f.write("runCommand=mv /usr/local/etc/devd/automount_devd"
190 | "_localdisks.conf.skip /usr/local/etc/devd/"
191 | "automount_devd_localdisks.conf\n")
192 | f.write("runCommand=echo '# For XHCI Mouse Support' >> /boot/loader.conf\n")
193 | f.write("runCommand=echo 'hw.usb.usbhid.enable=\"1\"' >> /boot/loader.conf\n")
194 | f.write("runCommand=echo 'usbhid_load=\"YES\"' >> /boot/loader.conf\n")
195 | f.write("runCommand=echo '# For UTouch Support' >> /boot/loader.conf\n")
196 | f.write("runCommand=echo 'utouch_load=\"YES\"' >> /boot/loader.conf\n")
197 | f.close()
198 |
--------------------------------------------------------------------------------
/src/disk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ghostbsd/gbi/511071276ed3ed1f8aaad10f0445403ebca2d679/src/disk.png
--------------------------------------------------------------------------------
/src/end.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | import gi
4 | gi.require_version('Gtk', '3.0')
5 | from gi.repository import Gtk
6 | from subprocess import Popen
7 |
8 | lyrics = """Installation is complete. You need to restart the
9 | computer in order to use the new installation.
10 | You can continue to use this live media, although
11 | any changes you make or documents you save will
12 | not be preserved on reboot."""
13 |
14 |
15 | class PyApp():
16 |
17 | def on_reboot(self, widget):
18 | Popen('shutdown -r now', shell=True)
19 | Gtk.main_quit()
20 |
21 | def on_close(self, widget):
22 | Gtk.main_quit()
23 |
24 | def __init__(self):
25 | window = Gtk.Window()
26 | window.set_border_width(8)
27 | window.connect("destroy", Gtk.main_quit)
28 | window.set_title("Installation Completed")
29 | window.set_icon_from_file("/usr/local/lib/gbi/image/logo.png")
30 | box1 = Gtk.VBox(False, 0)
31 | window.add(box1)
32 | box1.show()
33 | box2 = Gtk.VBox(False, 10)
34 | box2.set_border_width(10)
35 | box1.pack_start(box2, True, True, 0)
36 | box2.show()
37 | label = Gtk.Label(lyrics)
38 | box2.pack_start(label, True, True, 0)
39 | box2 = Gtk.HBox(False, 10)
40 | box2.set_border_width(5)
41 | box1.pack_start(box2, False, True, 0)
42 | box2.show()
43 | table = Gtk.Table(1, 2, True)
44 | restart = Gtk.Button("Restart")
45 | restart.connect("clicked", self.on_reboot)
46 | Continue = Gtk.Button("Continue")
47 | Continue.connect("clicked", self.on_close)
48 | table.attach(Continue, 0, 1, 0, 1)
49 | table.attach(restart, 1, 2, 0, 1)
50 | box2.pack_start(table, True, True, 0)
51 | window.show_all()
52 |
53 |
54 | PyApp()
55 | Gtk.main()
56 |
--------------------------------------------------------------------------------
/src/error.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | import gi
4 | gi.require_version('Gtk', '3.0')
5 | from gi.repository import Gtk
6 |
7 |
8 | class errorWindow():
9 |
10 | def on_close(self, widget):
11 | Gtk.main_quit()
12 |
13 | def __init__(self):
14 | window = Gtk.Window()
15 | window.set_border_width(8)
16 | window.connect("destroy", Gtk.main_quit)
17 | window.set_title("Installation Error")
18 | # window.set_icon_from_file("/usr/local/lib/gbi/image/logo.png")
19 | box1 = Gtk.VBox(homogeneous=False, spacing=0)
20 | window.add(box1)
21 | box1.show()
22 | box2 = Gtk.VBox(homogeneous=False, spacing=10)
23 | box2.set_border_width(10)
24 | box1.pack_start(box2, True, True, 0)
25 | box2.show()
26 | title = Gtk.Label()
27 | title.set_use_markup(True)
28 | title_text = 'Installation has failed!'
29 | title.set_markup(f'{title_text}')
30 | label = Gtk.Label()
31 | label.set_use_markup(True)
32 | url = 'https://github.com/ghostbsd/ghostbsd-src/issues/new/choose'
33 | anchor = f"GhostBSD issue system"
34 | message = f"Please report the issue to {anchor}, and \n" \
35 | "be sure to provide /tmp/.pc-sysinstall/pc-sysinstall.log."
36 | label.set_markup(message)
37 | box2.pack_start(title, True, True, 0)
38 | box2.pack_start(label, True, True, 0)
39 | box2 = Gtk.HBox(homogeneous=False, spacing=10)
40 | box2.set_border_width(5)
41 | box1.pack_start(box2, False, True, 0)
42 | box2.show()
43 | table = Gtk.Table(n_rows=1, n_columns=2, homogeneous=True)
44 | ok = Gtk.Button(label="Ok")
45 | ok.connect("clicked", self.on_close)
46 | table.attach(ok, 0, 2, 0, 1)
47 | box2.pack_start(table, True, True, 0)
48 | window.show_all()
49 |
50 |
51 | errorWindow()
52 | Gtk.main()
53 |
--------------------------------------------------------------------------------
/src/gbi.desktop:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env xdg-open
2 |
3 | [Desktop Entry]
4 | Version=1.0
5 | Terminal=false
6 | Type=Application
7 | Categories=GTK;System;
8 | NoDisplay=true
9 | Exec=gbi
10 | Name=Install GhostBSD
11 | Comment=Install GhostBSD
12 | Icon=/usr/local/lib/gbi/image/install-gbsd.png
13 |
--------------------------------------------------------------------------------
/src/gbiWindow.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """
3 | Copyright (c) 2010-2013, GhostBSD. All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions
7 | are met:
8 |
9 | 1. Redistribution's of source code must retain the above copyright
10 | notice, this list of conditions and the following disclaimer.
11 |
12 | 2. Redistribution's in binary form must reproduce the above
13 | copyright notice,this list of conditions and the following
14 | disclaimer in the documentation and/or other materials provided
15 | with the distribution.
16 |
17 | 3. Neither then name of GhostBSD Project nor the names of its
18 | contributors maybe used to endorse or promote products derived
19 | from this software without specific prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,
27 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | POSSIBILITY OF SUCH DAMAGE.
33 | """
34 |
35 | import sys
36 | import os
37 | import shutil
38 | import gi
39 | gi.require_version('Gtk', '3.0')
40 | from gi.repository import Gtk
41 | installer = "/usr/local/lib/gbi/"
42 | sys.path.append(installer)
43 | from language import Language
44 | from installType import Types
45 | from keyboard import Keyboard
46 | from timezone import TimeZone
47 | from use_ufs import use_ufs
48 | from partition import Partitions
49 | from use_zfs import ZFS
50 | from boot_manager import bootManager
51 | from add_admin import AddUser
52 | from partition_handler import create_disk_partition_db
53 | from install import installProgress, installWindow
54 | logo = "/usr/local/lib/gbi/image/logo.png"
55 | tmp = "/tmp/.gbi/"
56 | if not os.path.exists(tmp):
57 | os.makedirs(tmp)
58 | disk = '%sdisk' % tmp
59 | dslice = '%sslice' % tmp
60 | disk_schem = '%sscheme' % tmp
61 | zfs_config = '%szfs_config' % tmp
62 | ufs_config = '%sufs_config' % tmp
63 | partitiondb = "%spartitiondb/" % tmp
64 |
65 |
66 | class MainWindow():
67 | """Main window class."""
68 |
69 | def delete(self, widget, event=None):
70 | """Close the main window."""
71 | if os.path.exists('/tmp/.gbi'):
72 | shutil.rmtree('/tmp/.gbi')
73 | Gtk.main_quit()
74 | return False
75 |
76 | def next_page(self, widget, notebook):
77 | """Go to the next window."""
78 | page = self.notebook.get_current_page()
79 | if page == 0:
80 | self.lang.save_selection()
81 | kbbox = Gtk.VBox(False, 0)
82 | kbbox.show()
83 | self.kb = Keyboard(self.button3)
84 | get_kb = self.kb.get_model()
85 | kbbox.pack_start(get_kb, True, True, 0)
86 | label = Gtk.Label("Keyboard")
87 | self.notebook.insert_page(kbbox, label, 1)
88 | self.window.show_all()
89 | self.notebook.next_page()
90 | self.button1.set_sensitive(True)
91 | self.button3.set_sensitive(True)
92 | elif page == 1:
93 | self.kb.save_selection()
94 | tbbox = Gtk.VBox(False, 0)
95 | tbbox.show()
96 | self.tz = TimeZone(self.button3)
97 | get_tz = self.tz.get_model()
98 | tbbox.pack_start(get_tz, True, True, 0)
99 | label = Gtk.Label("TimeZone")
100 | self.notebook.insert_page(tbbox, label, 2)
101 | self.window.show_all()
102 | self.notebook.next_page()
103 | self.button3.set_sensitive(True)
104 | elif page == 2:
105 | self.tz.save_selection()
106 | typebox = Gtk.VBox(False, 0)
107 | typebox.show()
108 | self.types = Types()
109 | get_types = self.types.get_model()
110 | typebox.pack_start(get_types, True, True, 0)
111 | label = Gtk.Label("Types")
112 | self.notebook.insert_page(typebox, label, 3)
113 | self.window.show_all()
114 | self.notebook.next_page()
115 | elif page == 3:
116 | create_disk_partition_db()
117 | if self.types.get_type() == "ufs":
118 | udbox = Gtk.VBox(False, 0)
119 | udbox.show()
120 | self.partition = use_ufs(self.button3)
121 | get_ud = self.partition.get_model()
122 | udbox.pack_start(get_ud, True, True, 0)
123 | label = Gtk.Label("UFS Disk Configuration")
124 | self.notebook.insert_page(udbox, label, 4)
125 | self.window.show_all()
126 | self.notebook.next_page()
127 | self.button3.set_sensitive(False)
128 | elif self.types.get_type() == "custom":
129 | Pbox = Gtk.VBox(False, 0)
130 | Pbox.show()
131 | self.partition = Partitions(self.button3)
132 | get_part = self.partition.get_model()
133 | Pbox.pack_start(get_part, True, True, 0)
134 | label = Gtk.Label("UFS Custom Configuration")
135 | self.notebook.insert_page(Pbox, label, 4)
136 | self.window.show_all()
137 | self.notebook.next_page()
138 | self.button3.set_sensitive(False)
139 | elif self.types.get_type() == "zfs":
140 | Zbox = Gtk.VBox(False, 0)
141 | Zbox.show()
142 | self.partition = ZFS(self.button3)
143 | get_ZFS = self.partition.get_model()
144 | Zbox.pack_start(get_ZFS, True, True, 0)
145 | label = Gtk.Label("ZFS Configuration")
146 | self.notebook.insert_page(Zbox, label, 4)
147 | self.window.show_all()
148 | self.notebook.next_page()
149 | self.button3.set_sensitive(False)
150 | elif page == 4:
151 | self.partition.save_selection()
152 | Mbox = Gtk.VBox(False, 0)
153 | Mbox.show()
154 | self.bootmanager = bootManager()
155 | get_bootmanager = self.bootmanager.get_model()
156 | Mbox.pack_start(get_bootmanager, True, True, 0)
157 | label = Gtk.Label("Boot Option")
158 | self.notebook.insert_page(Mbox, label, 5)
159 | self.window.show_all()
160 | self.notebook.next_page()
161 | self.button3.set_sensitive(True)
162 | elif page == 5:
163 | Abox = Gtk.VBox(False, 0)
164 | Abox.show()
165 | self.adduser = AddUser(self.button3)
166 | get_adduser = self.adduser.get_model()
167 | Abox.pack_start(get_adduser, True, True, 0)
168 | label = Gtk.Label("Adding User")
169 | self.notebook.insert_page(Abox, label, 6)
170 | self.button3.set_label("Install")
171 | self.window.show_all()
172 | self.notebook.next_page()
173 | self.button3.set_sensitive(False)
174 | elif page == 6:
175 | self.adduser.save_selection()
176 | Ibox = Gtk.VBox(False, 0)
177 | Ibox.show()
178 | install = installWindow()
179 | get_install = install.get_model()
180 | Ibox.pack_start(get_install, True, True, 0)
181 | label = Gtk.Label("Installation")
182 | self.notebook.insert_page(Ibox, label, 7)
183 | self.notebook.next_page()
184 | instpro = installProgress(self.window)
185 | progressBar = instpro.getProgressBar()
186 | box1 = Gtk.VBox(False, 0)
187 | box1.show()
188 | label = Gtk.Label("Progress Bar")
189 | box1.pack_end(progressBar, False, False, 0)
190 | self.nbButton.insert_page(box1, label, 1)
191 | self.nbButton.next_page()
192 | self.window.show_all()
193 |
194 | def back_page(self, widget):
195 | """Go back to the previous window."""
196 | current_page = self.notebook.get_current_page()
197 | if current_page == 1:
198 | self.button1.set_sensitive(False)
199 | elif current_page == 7:
200 | self.button3.set_label("Next")
201 | self.notebook.prev_page()
202 | new_page = self.notebook.get_current_page()
203 | if current_page == 4 and new_page == 3:
204 | if os.path.exists(partitiondb):
205 | shutil.rmtree(partitiondb)
206 | if os.path.exists(tmp + 'create'):
207 | os.remove(tmp + 'create')
208 | if os.path.exists(tmp + 'delete'):
209 | os.remove(tmp + 'delete')
210 | if os.path.exists(tmp + 'destroy'):
211 | os.remove(tmp + 'destroy')
212 | if os.path.exists(tmp + 'partlabel'):
213 | os.remove(tmp + 'partlabel')
214 | if os.path.exists(zfs_config):
215 | os.remove(zfs_config)
216 | if os.path.exists(ufs_config):
217 | os.remove(ufs_config)
218 | if os.path.exists(disk):
219 | os.remove(disk)
220 | if os.path.exists(dslice):
221 | os.remove(dslice)
222 | if os.path.exists(disk_schem):
223 | os.remove(disk_schem)
224 | self.button3.set_sensitive(True)
225 |
226 | def __init__(self):
227 | """Were the Main window start."""
228 | self.window = Gtk.Window()
229 | self.window.connect("delete_event", self.delete)
230 | self.window.set_border_width(0)
231 | self.window.set_default_size(800, 500)
232 | self.window.set_size_request(800, 500)
233 | self.window.set_title("GhostBSD Installer")
234 | self.window.set_border_width(0)
235 | self.window.set_icon_from_file(logo)
236 | mainHBox = Gtk.HBox(False, 0)
237 | mainHBox.show()
238 | mainVbox = Gtk.VBox(False, 0)
239 | mainVbox.show()
240 | self.window.add(mainHBox)
241 | mainHBox.pack_start(mainVbox, True, True, 0)
242 | # Create a new self.notebook
243 | self.notebook = Gtk.Notebook()
244 | mainVbox.pack_start(self.notebook, True, True, 0)
245 | self.notebook.show()
246 | self.notebook.set_show_tabs(False)
247 | self.notebook.set_show_border(False)
248 | vbox = Gtk.VBox(False, 0)
249 | vbox.show()
250 | self.lang = Language()
251 | get_lang = self.lang.get_model()
252 | # self.lang = installWindow()
253 | # get_lang = self.lang.get_model()
254 | vbox.pack_start(get_lang, True, True, 0)
255 | label = Gtk.Label("Language")
256 | self.notebook.insert_page(vbox, label, 0)
257 |
258 | # Set what page to start at Language
259 | self.notebook.set_current_page(0)
260 |
261 | # Create buttons
262 | self.table = Gtk.Table(1, 6, True)
263 |
264 | self.button1 = Gtk.Button(label='Back')
265 | self.button1.connect("clicked", self.back_page)
266 | self.table.attach(self.button1, 3, 4, 0, 1)
267 | self.button1.show()
268 | self.button1.set_sensitive(False)
269 |
270 | self.button2 = Gtk.Button(label='Cancel')
271 | self.button2.connect("clicked", self.delete)
272 | self.table.attach(self.button2, 4, 5, 0, 1)
273 | self.button2.show()
274 |
275 | self.button3 = Gtk.Button(label='Next')
276 | self.button3.connect("clicked", self.next_page, self.notebook)
277 | self.table.attach(self.button3, 5, 6, 0, 1)
278 | self.button3.show()
279 |
280 | self.table.set_col_spacings(5)
281 | self.table.show()
282 | # Create a new notebook
283 | self.nbButton = Gtk.Notebook()
284 | mainVbox.pack_end(self.nbButton, False, False, 5)
285 | self.nbButton.show()
286 | self.nbButton.set_show_tabs(False)
287 | self.nbButton.set_show_border(False)
288 | label = Gtk.Label("Button")
289 | self.nbButton.insert_page(self.table, label, 0)
290 | self.window.show_all()
291 |
--------------------------------------------------------------------------------
/src/gbi_common.py:
--------------------------------------------------------------------------------
1 | import re
2 |
3 | be_name="default"
4 | # Default zfs datasets layout
5 | zfs_datasets = "/," \
6 | "/home(mountpoint=/home)," \
7 | "/tmp(mountpoint=/tmp|exec=on|setuid=off)," \
8 | "/usr(mountpoint=/usr|canmount=off)," \
9 | "/usr/ports(setuid=off)," \
10 | "/usr/src," \
11 | "/var(mountpoint=/var|canmount=off)," \
12 | "/var/audit(exec=off|setuid=off)," \
13 | "/var/crash(exec=off|setuid=off)," \
14 | "/var/log(exec=off|setuid=off)," \
15 | "/var/mail(atime=on)," \
16 | "/var/tmp(setuid=off)"
17 |
18 |
19 | # Find if pasword contain only lower case and number
20 | def lowerCase(strg, search=re.compile(r'[^a-z]').search):
21 | return not bool(search(strg))
22 |
23 |
24 | # Find if pasword contain only upper case
25 | def upperCase(strg, search=re.compile(r'[^A-Z]').search):
26 | return not bool(search(strg))
27 |
28 |
29 | # Find if pasword contain only lower case and number
30 | def lowerandNunber(strg, search=re.compile(r'[^a-z0-9]').search):
31 | return not bool(search(strg))
32 |
33 |
34 | # Find if pasword contain only upper case and number
35 | def upperandNunber(strg, search=re.compile(r'[^A-Z0-9]').search):
36 | return not bool(search(strg))
37 |
38 |
39 | # Find if pasword contain only lower and upper case and
40 | def lowerUpperCase(strg, search=re.compile(r'[^a-zA-Z]').search):
41 | return not bool(search(strg))
42 |
43 |
44 | # Find if pasword contain only lower and upper case and
45 | def lowerUpperNumber(strg, search=re.compile(r'[^a-zA-Z0-9]').search):
46 | return not bool(search(strg))
47 |
48 |
49 | # Find if password contain only lowercase, uppercase numbers
50 | # and some special character.
51 | def allCharacter(strg):
52 | search = re.compile(r'[^a-zA-Z0-9~\!@#\$%\^&\*_\+":;\'\-]').search
53 | return not bool(search(strg))
54 |
55 |
56 | def password_strength(password, label3):
57 | same_character_type = any(
58 | [
59 | lowerCase(password),
60 | upperCase(password),
61 | password.isdigit()
62 | ]
63 | )
64 | mix_character = any(
65 | [
66 | lowerandNunber(password),
67 | upperandNunber(password),
68 | lowerUpperCase(password)
69 | ]
70 | )
71 | if ' ' in password or '\t' in password:
72 | label3.set_text("Space not allowed")
73 | elif len(password) <= 4:
74 | label3.set_text("Super Weak")
75 | elif len(password) <= 8 and same_character_type:
76 | label3.set_text("Super Weak")
77 | elif len(password) <= 8 and mix_character:
78 | label3.set_text("Very Weak")
79 | elif len(password) <= 8 and lowerUpperNumber(password):
80 | label3.set_text("Fairly Weak")
81 | elif len(password) <= 8 and allCharacter(password):
82 | label3.set_text("Weak")
83 | elif len(password) <= 12 and same_character_type:
84 | label3.set_text("Very Weak")
85 | elif len(password) <= 12 and mix_character:
86 | label3.set_text("Fairly Weak")
87 | elif len(password) <= 12 and lowerUpperNumber(password):
88 | label3.set_text("Weak")
89 | elif len(password) <= 12 and allCharacter(password):
90 | label3.set_text("Strong")
91 | elif len(password) <= 16 and same_character_type:
92 | label3.set_text("Fairly Weak")
93 | elif len(password) <= 16 and mix_character:
94 | label3.set_text("Weak")
95 | elif len(password) <= 16 and lowerUpperNumber(password):
96 | label3.set_text("Strong")
97 | elif len(password) <= 16 and allCharacter(password):
98 | label3.set_text("Fairly Strong")
99 | elif len(password) <= 20 and same_character_type:
100 | label3.set_text("Weak")
101 | elif len(password) <= 20 and mix_character:
102 | label3.set_text("Strong")
103 | elif len(password) <= 20 and lowerUpperNumber(password):
104 | label3.set_text("Fairly Strong")
105 | elif len(password) <= 20 and allCharacter(password):
106 | label3.set_text("Very Strong")
107 | elif len(password) <= 24 and same_character_type:
108 | label3.set_text("Strong")
109 | elif len(password) <= 24 and mix_character:
110 | label3.set_text("Fairly Strong")
111 | elif len(password) <= 24 and lowerUpperNumber(password):
112 | label3.set_text("Very Strong")
113 | elif len(password) <= 24 and allCharacter(password):
114 | label3.set_text("Super Strong")
115 | elif same_character_type:
116 | label3.set_text("Fairly Strong")
117 | else:
118 | label3.set_text("Super Strong")
119 |
--------------------------------------------------------------------------------
/src/ghostbsd-style.css:
--------------------------------------------------------------------------------
1 | #install {
2 | background-image: url("/usr/local/lib/gbi/image/installation.jpg");
3 | background-size: cover;
4 | }
5 |
6 | #sideText {
7 | color: #F9F9F9;
8 | font-weight:bold;
9 | font-size: 14px;
10 | }
11 |
12 | #TransBox {
13 | background-color: rgba(0, 0, 0, 0.6)
14 | }
15 |
16 | #Header {
17 | color: #F9F9F9;
18 | background-color: #282828;
19 | font-size: 22px;
20 | }
21 |
--------------------------------------------------------------------------------
/src/image/G_logo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ghostbsd/gbi/511071276ed3ed1f8aaad10f0445403ebca2d679/src/image/G_logo.gif
--------------------------------------------------------------------------------
/src/image/disk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ghostbsd/gbi/511071276ed3ed1f8aaad10f0445403ebca2d679/src/image/disk.png
--------------------------------------------------------------------------------
/src/image/install-gbsd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ghostbsd/gbi/511071276ed3ed1f8aaad10f0445403ebca2d679/src/image/install-gbsd.png
--------------------------------------------------------------------------------
/src/image/install-gbsd.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
103 |
--------------------------------------------------------------------------------
/src/image/install.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ghostbsd/gbi/511071276ed3ed1f8aaad10f0445403ebca2d679/src/image/install.png
--------------------------------------------------------------------------------
/src/image/installation.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ghostbsd/gbi/511071276ed3ed1f8aaad10f0445403ebca2d679/src/image/installation.jpg
--------------------------------------------------------------------------------
/src/image/laptop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ghostbsd/gbi/511071276ed3ed1f8aaad10f0445403ebca2d679/src/image/laptop.png
--------------------------------------------------------------------------------
/src/image/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ghostbsd/gbi/511071276ed3ed1f8aaad10f0445403ebca2d679/src/image/logo.png
--------------------------------------------------------------------------------
/src/install.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | # install.py give the job to pc-sysinstall to install GhostBSD.
4 |
5 | import gi
6 | gi.require_version('Gtk', '3.0')
7 | from gi.repository import Gtk, GLib, Gdk
8 | import threading
9 | import os
10 | from subprocess import Popen, PIPE, STDOUT
11 | from time import sleep
12 | from partition_handler import deletePartition, destroyPartition, addPartition
13 | from create_cfg import GhostBSDCfg
14 | import sys
15 |
16 | gbi_dir = "/usr/local/lib/gbi"
17 | sys.path.append(gbi_dir)
18 | gbi_tmp = "/tmp/.gbi"
19 | pc_sysinstall = "/usr/local/sbin/pc-sysinstall"
20 |
21 |
22 | cssProvider = Gtk.CssProvider()
23 | cssProvider.load_from_path('/usr/local/lib/gbi/ghostbsd-style.css')
24 | screen = Gdk.Screen.get_default()
25 | styleContext = Gtk.StyleContext()
26 | styleContext.add_provider_for_screen(
27 | screen,
28 | cssProvider,
29 | Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
30 | )
31 |
32 |
33 | def update_progess(probar, bartext):
34 | new_val = probar.get_fraction() + 0.000003
35 | probar.set_fraction(new_val)
36 | probar.set_text(bartext[0:80])
37 |
38 |
39 | def read_output(command, probar, main_window):
40 | GLib.idle_add(update_progess, probar, "Creating pcinstall.cfg")
41 | GhostBSDCfg()
42 | sleep(1)
43 | if os.path.exists(f'{gbi_tmp}/delete'):
44 | GLib.idle_add(update_progess, probar, "Deleting partition")
45 | deletePartition()
46 | sleep(1)
47 | # destroy disk partition and create scheme
48 | if os.path.exists(f'{gbi_tmp}/destroy'):
49 | GLib.idle_add(update_progess, probar, "Creating disk partition")
50 | destroyPartition()
51 | sleep(1)
52 | # create partition
53 | if os.path.exists(f'{gbi_tmp}/create'):
54 | GLib.idle_add(update_progess, probar, "Creating new partitions")
55 | addPartition()
56 | sleep(1)
57 | p = Popen(command, shell=True, stdin=PIPE, stdout=PIPE,
58 | stderr=STDOUT, close_fds=True, universal_newlines=True)
59 | while True:
60 | line = p.stdout.readline()
61 | if not line:
62 | break
63 | bartext = line.rstrip()
64 | GLib.idle_add(update_progess, probar, bartext)
65 | # Those for next 4 line is for debugin only.
66 | # filer = open("/tmp/.gbi/tmp", "a")
67 | # filer.writelines(bartext)
68 | # filer.close
69 | print(bartext)
70 | if bartext.rstrip() == "Installation finished!":
71 | Popen(f'python {gbi_dir}/end.py', shell=True, close_fds=True)
72 | else:
73 | Popen(f'python {gbi_dir}/error.py', shell=True, close_fds=True)
74 | main_window.hide()
75 |
76 |
77 | class installWindow():
78 |
79 | def close_application(self, widget, event=None):
80 | Gtk.main_quit()
81 |
82 | def __init__(self):
83 | self.vBox = Gtk.VBox(False, 0)
84 | self.vBox.show()
85 | label = Gtk.Label("Installation in progress", name="Header")
86 | label.set_property("height-request", 50)
87 | self.vBox.pack_start(label, False, False, 0)
88 |
89 | hBox = Gtk.HBox(False, 0, name="install")
90 | hBox.show()
91 | self.vBox.pack_end(hBox, True, True, 0)
92 | vBox2 = Gtk.VBox(False, 0)
93 | vBox2.show()
94 | label2 = Gtk.Label(name="sideText")
95 |
96 | label2.set_markup("Thank you for choosing GhostBSD!\n\n"
97 | "We believe every computer operating system should "
98 | "be simple, elegant, secure and protect your privacy"
99 | " while being easy to use. GhostBSD is simplifying "
100 | "FreeBSD for those who lack the technical expertise "
101 | "required to use it and lower the entry-level of "
102 | "using BSD. \n\nWe hope you'll enjoy our BSD "
103 | "operating system.")
104 | label2.set_justify(Gtk.Justification.LEFT)
105 | label2.set_line_wrap(True)
106 | # label2.set_max_width_chars(10)
107 | label2.set_alignment(0.0, 0.2)
108 | hBox2 = Gtk.HBox(False, 0, name="TransBox")
109 | hBox2.show()
110 | hBox.pack_start(hBox2, True, True, 0)
111 | hBox2.pack_start(label2, True, True, 30)
112 |
113 | image = Gtk.Image()
114 | image.set_from_file(f"{gbi_dir}/image/G_logo.gif")
115 | # image.set_size_request(width=256, height=256)
116 | image.show()
117 | hBox.pack_end(image, True, True, 20)
118 |
119 | def get_model(self):
120 | return self.vBox
121 |
122 |
123 | class installProgress():
124 |
125 | def __init__(self, main_window):
126 | self.pbar = Gtk.ProgressBar()
127 | self.pbar.set_show_text(True)
128 | command = f'sudo {pc_sysinstall} -c {gbi_tmp}/pcinstall.cfg'
129 | thr = threading.Thread(
130 | target=read_output,
131 | args=(
132 | command,
133 | self.pbar,
134 | main_window
135 | )
136 | )
137 | thr.setDaemon(True)
138 | thr.start()
139 | self.pbar.show()
140 |
141 | def getProgressBar(self):
142 | return self.pbar
143 |
--------------------------------------------------------------------------------
/src/installType.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright (c) 2015 GhostBSD
4 | #
5 | # See COPYING for licence terms.
6 | #
7 | # type.py v 0.5 Thursday, Mar 28 2013 19:31:53 Eric Turgeon
8 | #
9 | # type.py create and delete partition slice for GhostBSD system.
10 |
11 | import gi
12 | gi.require_version('Gtk', '3.0')
13 | from gi.repository import Gtk, Gdk
14 | import os
15 | import os.path
16 |
17 | # Folder use pr the installer.
18 | tmp = "/tmp/.gbi/"
19 | installer = "/usr/local/lib/gbi/"
20 | query = "sh /usr/local/etc/lib/backend-query/"
21 | if not os.path.exists(tmp):
22 | os.makedirs(tmp)
23 |
24 | disk_file = '%sdisk' % tmp
25 | boot_file = '%sboot' % tmp
26 | signal = '%ssignal' % tmp
27 | disk_list = '%sdisk-list.sh' % query
28 | disk_info = '%sdisk-info.sh' % query
29 | part_query = '%sdisk-part.sh' % query
30 |
31 | cssProvider = Gtk.CssProvider()
32 | cssProvider.load_from_path('/usr/local/lib/gbi/ghostbsd-style.css')
33 | screen = Gdk.Screen.get_default()
34 | styleContext = Gtk.StyleContext()
35 | styleContext.add_provider_for_screen(
36 | screen,
37 | cssProvider,
38 | Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
39 | )
40 |
41 |
42 | class Types():
43 |
44 | def fstype(self, radiobutton, val):
45 | self.ne = val
46 | pass_file = open(signal, 'w')
47 | pass_file.writelines(self.ne)
48 | pass_file.close
49 | return
50 |
51 | def get_type(self):
52 | return self.ne
53 |
54 | def get_model(self):
55 | return self.vbox1
56 |
57 | def __init__(self):
58 | self.vbox1 = Gtk.VBox(False, 0)
59 | self.vbox1.show()
60 | Title = Gtk.Label('Installation Type', name="Header")
61 | Title.set_property("height-request", 50)
62 | self.vbox1.pack_start(Title, False, False, 0)
63 | vbox2 = Gtk.VBox()
64 | hbox1 = Gtk.HBox()
65 | self.ne = 'zfs'
66 | pass_file = open(signal, 'w')
67 | pass_file.writelines(self.ne)
68 | pass_file.close
69 | self.vbox1.pack_start(hbox1, False, False, 10)
70 | full_zfs = Gtk.RadioButton.new_with_label_from_widget(
71 | None,
72 | "Full disk configuration"
73 | )
74 | vbox2.pack_start(full_zfs, False, True, 10)
75 | full_zfs.connect("toggled", self.fstype, "zfs")
76 | full_zfs.show()
77 | # full_ufs = Gtk.RadioButton()
78 | # full_ufs.new_with_label_from_widget(full_zfs,
79 | # "UFS full disk configuration")
80 | # vbox2.pack_start(full_ufs, False, True, 10)
81 | # full_ufs.connect("toggled", self.fstype, "ufs")
82 | # full_ufs.show()
83 | custom_ufs = Gtk.RadioButton.new_with_label_from_widget(
84 | full_zfs,
85 | "Custom (Advanced partitioning)"
86 | )
87 | vbox2.pack_start(custom_ufs, False, True, 10)
88 | custom_ufs.connect("toggled", self.fstype, "custom")
89 | custom_ufs.show()
90 | hbox1.pack_start(vbox2, False, False, 50)
91 | full_zfs.set_active(True)
92 |
--------------------------------------------------------------------------------
/src/keyboard.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | from gi.repository import Gtk, Gdk
4 | import os
5 | from sys_handler import (
6 | keyboard_dictionary,
7 | keyboard_models,
8 | change_keyboard,
9 | set_keyboard
10 |
11 | )
12 |
13 | # Folder use for the installer.
14 | tmp = "/tmp/.gbi/"
15 | installer = "/usr/local/lib/gbi/"
16 | query = "sh /usr/local/lib/gbi/backend-query/"
17 |
18 | if not os.path.exists(tmp):
19 | os.makedirs(tmp)
20 |
21 | layout = '%slayout' % tmp
22 | variant = '%svariant' % tmp
23 | KBFile = '%skeyboard' % tmp
24 | kb_dictionary = keyboard_dictionary()
25 | kbm_dictionary = keyboard_models()
26 |
27 | cssProvider = Gtk.CssProvider()
28 | cssProvider.load_from_path('/usr/local/lib/gbi/ghostbsd-style.css')
29 | screen = Gdk.Screen.get_default()
30 | styleContext = Gtk.StyleContext()
31 | styleContext.add_provider_for_screen(
32 | screen,
33 | cssProvider,
34 | Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
35 | )
36 |
37 |
38 | # This class is for placeholder for entry.
39 | class PlaceholderEntry(Gtk.Entry):
40 |
41 | placeholder = 'Type here to test your keyboard'
42 | _default = True
43 |
44 | def __init__(self, *args, **kwds):
45 | Gtk.Entry.__init__(self, *args, **kwds)
46 | self.set_text(self.placeholder)
47 | # self.modify_text(Gtk.STATE_NORMAL, Gtk.gdk.color_parse("#4d4d4d"))
48 | self._default = True
49 | self.connect('focus-in-event', self._focus_in_event)
50 | self.connect('focus-out-event', self._focus_out_event)
51 |
52 | def _focus_in_event(self, widget, event):
53 | if self._default:
54 | self.set_text('')
55 | # self.modify_text(Gtk.STATE_NORMAL, Gtk.gdk.color_parse('black'))
56 |
57 | def _focus_out_event(self, widget, event):
58 | if Gtk.Entry.get_text(self) == '':
59 | self.set_text(self.placeholder)
60 | # self.modify_text(Gtk.STATE_NORMAL,
61 | # Gtk.gdk.color_parse("#4d4d4d"))
62 | self._default = True
63 | else:
64 | self._default = False
65 |
66 | def get_text(self):
67 | if self._default:
68 | return ''
69 | return Gtk.Entry.get_text(self)
70 |
71 |
72 | class Keyboard:
73 | def layout_columns(self, treeView):
74 | cell = Gtk.CellRendererText()
75 | column = Gtk.TreeViewColumn(None, cell, text=0)
76 | column_header = Gtk.Label('Keyboard Layout')
77 | column_header.set_use_markup(True)
78 | column_header.show()
79 | column.set_widget(column_header)
80 | column.set_sort_column_id(0)
81 | treeView.append_column(column)
82 |
83 | def variant_columns(self, treeView):
84 | cell = Gtk.CellRendererText()
85 | column = Gtk.TreeViewColumn(None, cell, text=0)
86 | column_header = Gtk.Label('Keyboard Models')
87 | column_header.set_use_markup(True)
88 | column_header.show()
89 | column.set_widget(column_header)
90 | column.set_sort_column_id(0)
91 | treeView.append_column(column)
92 |
93 | def Selection_Layout(self, tree_selection, button3):
94 | model, treeiter = tree_selection.get_selected()
95 | if treeiter is not None:
96 | value = model[treeiter][0]
97 | kb_lv = kb_dictionary[value]
98 | self.kb_layout = kb_lv['layout']
99 | self.kb_variant = kb_lv['variant']
100 | change_keyboard(self.kb_layout, self.kb_variant)
101 | button3.set_sensitive(True)
102 | else:
103 | button3.set_sensitive(False)
104 |
105 | def Selection_Model(self, tree_selection):
106 | model, treeiter = tree_selection.get_selected()
107 | if treeiter is not None:
108 | value = model[treeiter][0]
109 | self.kb_model = kbm_dictionary[value]
110 | change_keyboard(self.kb_layout, self.kb_variant, self.kb_model)
111 |
112 | def get_model(self):
113 | self.treeView.set_cursor(0)
114 | self.button3.set_sensitive(True)
115 | return self.vbox1
116 |
117 | def save_selection(self):
118 | File = open(KBFile, 'w')
119 | File.writelines("%s\n" % self.kb_layout)
120 | File.writelines("%s\n" % self.kb_variant)
121 | File.writelines("%s\n" % self.kb_model)
122 | File.close()
123 | return
124 |
125 | def save_keyboard(self):
126 | set_keyboard(self.kb_layout, self.kb_variant, self.kb_model)
127 |
128 | def __init__(self, button3):
129 | self.button3 = button3
130 | self.vbox1 = Gtk.VBox(False, 0)
131 | self.vbox1.show()
132 | Title = Gtk.Label('Keyboard Setup', name="Header")
133 | Title.set_property("height-request", 50)
134 | self.vbox1.pack_start(Title, False, False, 0)
135 | vbox2 = Gtk.VBox(False, 10)
136 | vbox2.set_border_width(10)
137 | self.vbox1.pack_start(vbox2, True, True, 0)
138 | vbox2.show()
139 | table = Gtk.Table(1, 2, True)
140 | vbox2.pack_start(table, False, False, 0)
141 | hbox1 = Gtk.HBox(False, 10)
142 | hbox1.set_border_width(5)
143 | vbox2.pack_start(hbox1, True, True, 5)
144 | hbox1.show()
145 |
146 | sw = Gtk.ScrolledWindow()
147 | sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
148 | sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
149 | store = Gtk.TreeStore(str)
150 | store.append(None, ['English (US)'])
151 | store.append(None, ['English (Canada)'])
152 | store.append(None, ['French (Canada)'])
153 | for line in sorted(kb_dictionary):
154 | store.append(None, [line.rstrip()])
155 | self.treeView = Gtk.TreeView(store)
156 | self.treeView.set_model(store)
157 | self.treeView.set_rules_hint(True)
158 | self.layout_columns(self.treeView)
159 | self.tree_selection = self.treeView.get_selection()
160 | self.tree_selection.set_mode(Gtk.SelectionMode.SINGLE)
161 | self.tree_selection.connect("changed", self.Selection_Layout, button3)
162 | sw.add(self.treeView)
163 | sw.show()
164 | hbox1.pack_start(sw, True, True, 5)
165 |
166 | sw = Gtk.ScrolledWindow()
167 | sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
168 | sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
169 | self.kb_model = None
170 | self.model_store = Gtk.TreeStore(str)
171 | for line in sorted(kbm_dictionary):
172 | self.model_store.append(None, [line.rstrip()])
173 | treeView = Gtk.TreeView(self.model_store)
174 | treeView.set_model(self.model_store)
175 | treeView.set_rules_hint(True)
176 | self.variant_columns(treeView)
177 | tree_selection = treeView.get_selection()
178 | tree_selection.set_mode(Gtk.SelectionMode.SINGLE)
179 | tree_selection.connect("changed", self.Selection_Model)
180 | sw.add(treeView)
181 | sw.show()
182 | hbox1.pack_start(sw, True, True, 5)
183 |
184 | vbox3 = Gtk.HBox(False, 10)
185 | vbox3.set_border_width(5)
186 | self.vbox1.pack_start(vbox3, False, False, 0)
187 | vbox3.show()
188 | vbox3.pack_start(PlaceholderEntry(), True, True, 10)
189 |
--------------------------------------------------------------------------------
/src/language.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | from gi.repository import Gtk, Gdk
4 | import os
5 | import os.path
6 | from sys_handler import (
7 | language_dictionary,
8 | localize_system
9 | )
10 |
11 | # Folder use for the installer.
12 | tmp = "/tmp/.gbi/"
13 | installer = "/usr/local/lib/gbi/"
14 | query = "sh /usr/local/lib/gbi/backend-query/"
15 | if not os.path.exists(tmp):
16 | os.makedirs(tmp)
17 |
18 | logo = "/usr/local/lib/gbi/image/logo.png"
19 | langfile = '%slanguage' % tmp
20 | lang_dictionary = language_dictionary()
21 | # Text to be replace be multiple language file.
22 | welltext = """Select the language you want to use with GhostBSD."""
23 |
24 | cssProvider = Gtk.CssProvider()
25 | cssProvider.load_from_path('/usr/local/lib/gbi/ghostbsd-style.css')
26 | screen = Gdk.Screen.get_default()
27 | styleContext = Gtk.StyleContext()
28 | styleContext.add_provider_for_screen(
29 | screen,
30 | cssProvider,
31 | Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
32 | )
33 |
34 |
35 | class Language:
36 |
37 | # On selection it overwrite the delfaut language file.
38 | def Language_Selection(self, tree_selection):
39 | model, treeiter = tree_selection.get_selected()
40 | if treeiter is not None:
41 | value = model[treeiter][0]
42 | self.language = lang_dictionary[value]
43 | return
44 |
45 | def Language_Columns(self, treeView):
46 | cell = Gtk.CellRendererText()
47 | column = Gtk.TreeViewColumn(None, cell, text=0)
48 | column_header = Gtk.Label('Language')
49 | column_header.set_use_markup(True)
50 | column_header.show()
51 | column.set_widget(column_header)
52 | column.set_sort_column_id(0)
53 | treeView.append_column(column)
54 | return
55 |
56 | def save_selection(self):
57 | lang_file = open(langfile, 'w')
58 | lang_file.writelines(self.language)
59 | lang_file.close()
60 | return
61 |
62 | def save_language(self):
63 | localize_system(self.language)
64 |
65 | # Initial definition.
66 | def __init__(self):
67 | # Add a Default vertical box
68 | self.vbox1 = Gtk.VBox(False, 0)
69 | self.vbox1.show()
70 | # Add a second vertical box
71 | grid = Gtk.Grid()
72 | Title = Gtk.Label('Welcome To GhostBSD!', name="Header")
73 | Title.set_property("height-request", 50)
74 | self.vbox1.pack_start(Title, False, False, 0)
75 | self.vbox1.pack_start(grid, True, True, 0)
76 | grid.set_row_spacing(10)
77 | grid.set_column_spacing(3)
78 | grid.set_column_homogeneous(True)
79 | grid.set_row_homogeneous(True)
80 | grid.set_margin_left(10)
81 | grid.set_margin_right(10)
82 | grid.set_margin_top(10)
83 | grid.set_margin_bottom(10)
84 | # Adding a Scrolling Window
85 | sw = Gtk.ScrolledWindow()
86 | sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
87 | sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
88 | # Adding a treestore and store language in it.
89 | store = Gtk.TreeStore(str)
90 | for line in lang_dictionary:
91 | store.append(None, [line])
92 | treeView = Gtk.TreeView(store)
93 | treeView.set_model(store)
94 | treeView.set_rules_hint(True)
95 | self.Language_Columns(treeView)
96 | tree_selection = treeView.get_selection()
97 | tree_selection.set_mode(Gtk.SelectionMode.SINGLE)
98 | tree_selection.connect("changed", self.Language_Selection)
99 | sw.add(treeView)
100 | sw.show()
101 | grid.attach(sw, 1, 2, 1, 9)
102 | # add text in a label.
103 | vbox2 = Gtk.VBox(False, 0)
104 | vbox2.set_border_width(10)
105 | vbox2.show()
106 | self.wellcometext = Gtk.Label(welltext)
107 | self.wellcometext.set_use_markup(True)
108 | table = Gtk.Table()
109 | # wall = Gtk.Label()
110 | # table.attach(wall, 0, 1, 2, 3)
111 | table.attach(self.wellcometext, 0, 1, 3, 4)
112 | vbox2.pack_start(table, False, False, 5)
113 | image = Gtk.Image()
114 | image.set_from_file(logo)
115 | image.show()
116 | # grid.attach(self.wellcome, 1, 1, 3, 1)
117 | vbox2.pack_start(image, True, True, 5)
118 | grid.attach(vbox2, 2, 2, 2, 9)
119 | grid.show()
120 | return
121 |
122 | def get_model(self):
123 | return self.vbox1
124 |
--------------------------------------------------------------------------------
/src/laptop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ghostbsd/gbi/511071276ed3ed1f8aaad10f0445403ebca2d679/src/laptop.png
--------------------------------------------------------------------------------
/src/network_setup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright (c) 2020 GhostBSD
4 |
5 | import gi
6 | gi.require_version('Gtk', '3.0')
7 | from gi.repository import Gtk, Gdk, GLib, GdkPixbuf
8 | import re
9 | import sys
10 | import _thread
11 | from time import sleep
12 | networkmgr = "/usr/local/share/networkmgr"
13 | sys.path.append(networkmgr)
14 | from NetworkMgr.net_api import (
15 | networkdictionary,
16 | connectToSsid,
17 | delete_ssid_wpa_supplicant_config,
18 | nic_status
19 | )
20 |
21 | logo = "/usr/local/lib/gbi/logo.png"
22 | cssProvider = Gtk.CssProvider()
23 | cssProvider.load_from_path('/usr/local/lib/gbi/ghostbsd-style.css')
24 | screen = Gdk.Screen.get_default()
25 | styleContext = Gtk.StyleContext()
26 | styleContext.add_provider_for_screen(
27 | screen,
28 | cssProvider,
29 | Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
30 | )
31 |
32 |
33 | class network_setup():
34 |
35 | def get_model(self):
36 | return self.vbox1
37 |
38 | def wifi_stat(self, bar):
39 | if bar > 75:
40 | return 'nm-signal-100'
41 | elif bar > 50:
42 | return 'nm-signal-75'
43 | elif bar > 25:
44 | return 'nm-signal-50'
45 | elif bar > 5:
46 | return 'nm-signal-25'
47 | else:
48 | return 'nm-signal-00'
49 |
50 | def secure_wifi(self, bar):
51 | img = Gtk.Image()
52 | if bar > 90:
53 | img.set_from_icon_name("nm-signal-100-secure", Gtk.IconSize.MENU)
54 | elif bar > 65:
55 | img.set_from_icon_name("nm-signal-75-secure", Gtk.IconSize.MENU)
56 | elif bar > 40:
57 | img.set_from_icon_name("nm-signal-50-secure", Gtk.IconSize.MENU)
58 | elif bar > 15:
59 | img.set_from_icon_name("nm-signal-25-secure", Gtk.IconSize.MENU)
60 | else:
61 | img.set_from_icon_name("nm-signal-00-secure", Gtk.IconSize.MENU)
62 | img.show()
63 | return img
64 |
65 | def update_network_detection(self):
66 | cards = self.network_info['cards']
67 | card_list = list(cards.keys())
68 | r = re.compile("wlan")
69 | wlan_list = list(filter(r.match, card_list))
70 | wire_list = list(set(card_list).difference(wlan_list))
71 | cards = self.network_info['cards']
72 | if wire_list:
73 | for card in wire_list:
74 | if cards[card]['state']['connection'] == 'Connected':
75 |
76 | wire_text = 'Network card connected to the internet'
77 | self.wire_connection_image.set_from_stock(Gtk.STOCK_YES, 5)
78 | print('Connected True')
79 | self.next_button.set_sensitive(True)
80 | break
81 | else:
82 | wire_text = 'Network card not connected to the internet'
83 | self.wire_connection_image.set_from_stock(Gtk.STOCK_NO, 5)
84 | else:
85 | wire_text = 'No network card detected'
86 | self.wire_connection_image.set_from_stock(Gtk.STOCK_NO, 5)
87 |
88 | self.wire_connection_label.set_label(wire_text)
89 |
90 | if wlan_list:
91 | for wlan_card in wlan_list:
92 | if cards[wlan_card]['state']['connection'] == 'Connected':
93 | wifi_text = 'WiFi card detected and connected to an ' \
94 | 'access point'
95 | self.wifi_connection_image.set_from_stock(Gtk.STOCK_YES, 5)
96 | break
97 | else:
98 | wifi_text = 'WiFi card detected but not connected to an ' \
99 | 'access point'
100 | self.wifi_connection_image.set_from_stock(Gtk.STOCK_NO, 5)
101 | else:
102 | wlan_card = "WiFi card not detected or not supported"
103 | self.wifi_connection_image.set_from_stock(Gtk.STOCK_NO, 5)
104 |
105 | self.wifi_connection_label.set_label(wifi_text)
106 |
107 | def __init__(self, next_button):
108 | self.next_button = next_button
109 | self.network_info = networkdictionary()
110 | print(self.network_info)
111 | self.vbox1 = Gtk.VBox(homogeneous=False, spacing=0)
112 | self.vbox1.show()
113 | Title = Gtk.Label(label='Network Setup', name="Header")
114 | Title.set_property("height-request", 50)
115 | self.vbox1.pack_start(Title, False, False, 0)
116 | cards = self.network_info['cards']
117 | card_list = list(cards.keys())
118 | r = re.compile("wlan")
119 | wlan_list = list(filter(r.match, card_list))
120 | wire_list = list(set(card_list).difference(wlan_list))
121 |
122 | self.wire_connection_label = Gtk.Label()
123 | self.wire_connection_label.set_xalign(0.01)
124 | self.wire_connection_image = Gtk.Image()
125 | self.wifi_connection_label = Gtk.Label()
126 | self.wifi_connection_label.set_xalign(0.01)
127 | self.wifi_connection_image = Gtk.Image()
128 |
129 | if wire_list:
130 | for card in wire_list:
131 | if cards[card]['state']['connection'] == 'Connected':
132 | wire_text = 'Network card connected to the internet'
133 | self.wire_connection_image.set_from_stock(Gtk.STOCK_YES, 5)
134 | print('Connected True')
135 | self.next_button.set_sensitive(True)
136 | break
137 | else:
138 | wire_text = 'Network card not connected to the internet'
139 | self.wire_connection_image.set_from_stock(Gtk.STOCK_NO, 5)
140 | else:
141 | wire_text = 'No network card detected'
142 | self.wire_connection_image.set_from_stock(Gtk.STOCK_NO, 5)
143 |
144 | self.wire_connection_label.set_label(wire_text)
145 |
146 | if wlan_list:
147 | for wlan_card in wlan_list:
148 | if cards[wlan_card]['state']['connection'] == 'Connected':
149 | wifi_text = 'WiFi card detected and connected to an ' \
150 | 'access point'
151 | self.wifi_connection_image.set_from_stock(Gtk.STOCK_YES, 5)
152 | break
153 | else:
154 | wifi_text = 'WiFi card detected but not connected to an ' \
155 | 'access point'
156 | self.wifi_connection_image.set_from_stock(Gtk.STOCK_NO, 5)
157 | else:
158 | wlan_card = ""
159 | wifi_text = 'WiFi card not detected or not supported'
160 | self.wifi_connection_image.set_from_stock(Gtk.STOCK_NO, 5)
161 |
162 | self.wifi_connection_label.set_label(wifi_text)
163 |
164 | self.connection_box = Gtk.HBox(homogeneous=True, spacing=20)
165 | if wlan_card:
166 | # add a default card variable
167 | sw = Gtk.ScrolledWindow()
168 | sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
169 | sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
170 | self.store = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str)
171 | for ssid in self.network_info['cards'][wlan_card]['info']:
172 | ssid_info = self.network_info['cards'][wlan_card]['info'][ssid]
173 | bar = ssid_info[4]
174 | stat = self.wifi_stat(bar)
175 | pixbuf = Gtk.IconTheme.get_default().load_icon(stat, 32, 0)
176 | self.store.append([pixbuf, ssid, f'{ssid_info}'])
177 | treeView = Gtk.TreeView(self.store)
178 | treeView.set_model(self.store)
179 | treeView.set_rules_hint(True)
180 | pixbuf_cell = Gtk.CellRendererPixbuf()
181 | pixbuf_column = Gtk.TreeViewColumn('Stat', pixbuf_cell)
182 | pixbuf_column.add_attribute(pixbuf_cell, "pixbuf", 0)
183 | pixbuf_column.set_resizable(True)
184 | treeView.append_column(pixbuf_column)
185 | cell = Gtk.CellRendererText()
186 | column = Gtk.TreeViewColumn('SSID', cell, text=1)
187 | column.set_sort_column_id(1)
188 | treeView.append_column(column)
189 | tree_selection = treeView.get_selection()
190 | tree_selection.set_mode(Gtk.SelectionMode.SINGLE)
191 | tree_selection.connect("changed", self.wifi_setup, wlan_card)
192 | sw.add(treeView)
193 | self.connection_box.pack_start(sw, True, True, 50)
194 |
195 | main_grid = Gtk.Grid()
196 | main_grid.set_row_spacing(10)
197 | main_grid.set_column_spacing(10)
198 | main_grid.set_column_homogeneous(True)
199 | main_grid.set_row_homogeneous(True)
200 | self.vbox1.pack_start(main_grid, True, True, 10)
201 | main_grid.attach(self.wire_connection_image, 2, 1, 1, 1)
202 | main_grid.attach(self.wire_connection_label, 3, 1, 8, 1)
203 | main_grid.attach(self.wifi_connection_image, 2, 2, 1, 1)
204 | main_grid.attach(self.wifi_connection_label, 3, 2, 8, 1)
205 | main_grid.attach(self.connection_box, 1, 4, 10, 5)
206 |
207 | def wifi_setup(self, tree_selection, wificard):
208 | model, treeiter = tree_selection.get_selected()
209 | if treeiter is not None:
210 | ssid = model[treeiter][1]
211 | self.network_info['cards'][wificard]['info']
212 | ssid_info = self.network_info['cards'][wificard]['info'][ssid]
213 | caps = ssid_info[6]
214 | print(ssid) # added the code to authenticate.
215 | print(ssid_info)
216 | if caps == 'E' or caps == 'ES':
217 | if f'"{ssid}"' in open("/etc/wpa_supplicant.conf").read():
218 | self.try_to_connect_to_ssid(ssid, ssid_info, wificard)
219 | else:
220 | self.Open_Wpa_Supplicant(ssid, wificard)
221 | self.try_to_connect_to_ssid(ssid, ssid_info, wificard)
222 | else:
223 | if f'"{ssid}"' in open('/etc/wpa_supplicant.conf').read():
224 | self.try_to_connect_to_ssid(ssid, ssid_info, wificard)
225 | else:
226 | self.Authentication(ssid_info, wificard, False)
227 | return
228 |
229 | def add_to_wpa_supplicant(self, widget, ssid_info, card):
230 | pwd = self.password.get_text()
231 | self.setup_wpa_supplicant(ssid_info[0], ssid_info, pwd, card)
232 | _thread.start_new_thread(
233 | self.try_to_connect_to_ssid,
234 | (ssid_info[0], ssid_info, card)
235 | )
236 | self.window.hide()
237 |
238 | def try_to_connect_to_ssid(self, ssid, ssid_info, card):
239 | if connectToSsid(ssid, card) is False:
240 | delete_ssid_wpa_supplicant_config(ssid)
241 | GLib.idle_add(self.restart_authentication, ssid_info, card)
242 | else:
243 | for _ in list(range(30)):
244 | if nic_status(card) == 'associated':
245 | self.network_info = networkdictionary()
246 | print(self.network_info)
247 | self.update_network_detection()
248 | break
249 | sleep(1)
250 | else:
251 | delete_ssid_wpa_supplicant_config(ssid)
252 | GLib.idle_add(self.restart_authentication, ssid_info, card)
253 | return
254 |
255 | def restart_authentication(self, ssid_info, card):
256 | self.Authentication(ssid_info, card, True)
257 |
258 | def on_check(self, widget):
259 | if widget.get_active():
260 | self.password.set_visibility(True)
261 | else:
262 | self.password.set_visibility(False)
263 |
264 | def Authentication(self, ssid_info, card, failed):
265 | self.window = Gtk.Window()
266 | self.window.set_title("wi-Fi Network Authentication Required")
267 | self.window.set_border_width(0)
268 | self.window.set_size_request(500, 200)
269 | box1 = Gtk.VBox(False, 0)
270 | self.window.add(box1)
271 | box1.show()
272 | box2 = Gtk.VBox(False, 10)
273 | box2.set_border_width(10)
274 | box1.pack_start(box2, True, True, 0)
275 | box2.show()
276 | # Creating MBR or GPT drive
277 | if failed:
278 | title = f"{ssid_info[0]} Wi-Fi Network Authentication failed"
279 | else:
280 | title = f"Authentication required by {ssid_info[0]} Wi-Fi Network"
281 | label = Gtk.Label(f"{title}")
282 | label.set_use_markup(True)
283 | pwd_label = Gtk.Label("Password:")
284 | self.password = Gtk.Entry()
285 | self.password.set_visibility(False)
286 | check = Gtk.CheckButton("Show password")
287 | check.connect("toggled", self.on_check)
288 | table = Gtk.Table(1, 2, True)
289 | table.attach(label, 0, 5, 0, 1)
290 | table.attach(pwd_label, 1, 2, 2, 3)
291 | table.attach(self.password, 2, 4, 2, 3)
292 | table.attach(check, 2, 4, 3, 4)
293 | box2.pack_start(table, False, False, 0)
294 | box2 = Gtk.HBox(False, 10)
295 | box2.set_border_width(5)
296 | box1.pack_start(box2, False, True, 0)
297 | box2.show()
298 | # Add create_scheme button
299 | cancel = Gtk.Button(stock=Gtk.STOCK_CANCEL)
300 | cancel.connect("clicked", self.close)
301 | connect = Gtk.Button(stock=Gtk.STOCK_CONNECT)
302 | connect.connect("clicked", self.add_to_wpa_supplicant, ssid_info, card)
303 | table = Gtk.Table(1, 2, True)
304 | table.set_col_spacings(10)
305 | table.attach(connect, 4, 5, 0, 1)
306 | table.attach(cancel, 3, 4, 0, 1)
307 | box2.pack_end(table, True, True, 5)
308 | self.window.show_all()
309 | return 'Done'
310 |
311 | def close(self, widget):
312 | self.window.hide()
313 |
314 | def setup_wpa_supplicant(self, ssid, ssid_info, pwd, card):
315 | if 'RSN' in ssid_info[-1]:
316 | ws = '\nnetwork={'
317 | ws += f'\n ssid="{ssid}"'
318 | ws += '\n key_mgmt=WPA-PSK'
319 | ws += '\n proto=RSN'
320 | ws += f'\n psk="{pwd}"\n'
321 | ws += '}\n'
322 | elif 'WPA' in ssid_info[-1]:
323 | ws = '\nnetwork={'
324 | ws += f'\n ssid="{ssid}"'
325 | ws += '\n key_mgmt=WPA-PSK'
326 | ws += '\n proto=WPA'
327 | ws += f'\n psk="{pwd}"\n'
328 | ws += '}\n'
329 | else:
330 | ws = '\nnetwork={'
331 | ws += f'\n ssid="{ssid}"'
332 | ws += '\n key_mgmt=NONE'
333 | ws += '\n wep_tx_keyidx=0'
334 | ws += f'\n wep_key0={pwd}\n'
335 | ws += '}\n'
336 | wsf = open("/etc/wpa_supplicant.conf", 'a')
337 | wsf.writelines(ws)
338 | wsf.close()
339 |
340 | def Open_Wpa_Supplicant(self, ssid, card):
341 | ws = '\nnetwork={'
342 | ws += f'\n ssid={ssid}'
343 | ws += '\n key_mgmt=NONE\n}\n'
344 | wsf = open("/etc/wpa_supplicant.conf", 'a')
345 | wsf.writelines(ws)
346 | wsf.close()
347 |
--------------------------------------------------------------------------------
/src/setup_system.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | import gi
4 | gi.require_version('Gtk', '3.0')
5 | from gi.repository import Gtk, GLib, Gdk
6 | import threading
7 | from time import sleep
8 |
9 | gbi_dir = "/usr/local/lib/gbi"
10 | gbi_tmp = "/tmp/.gbi"
11 | pc_sysinstall = "/usr/local/sbin/pc-sysinstall"
12 |
13 |
14 | cssProvider = Gtk.CssProvider()
15 | cssProvider.load_from_path('/usr/local/lib/gbi/ghostbsd-style.css')
16 | screen = Gdk.Screen.get_default()
17 | styleContext = Gtk.StyleContext()
18 | styleContext.add_provider_for_screen(
19 | screen,
20 | cssProvider,
21 | Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
22 | )
23 |
24 |
25 | def update_progess(probar, bartext):
26 | new_val = probar.get_fraction() + 0.000003
27 | probar.set_fraction(new_val)
28 | probar.set_text(bartext[0:80])
29 |
30 |
31 | def read_output(command, probar, main_window, welcome, kb, tz, adminuser):
32 | GLib.idle_add(update_progess, probar, "Setting system language")
33 | welcome.save_language()
34 | sleep(1)
35 | GLib.idle_add(update_progess, probar, "Setting system language")
36 | kb.save_keyboard()
37 | sleep(1)
38 | GLib.idle_add(update_progess, probar, "Setting system language")
39 | tz.save_timezone()
40 | sleep(1)
41 | GLib.idle_add(update_progess, probar, "Setting system language")
42 | adminuser.save_adminuser()
43 | sleep(1)
44 | GLib.idle_add(update_progess, probar, "Setting system language")
45 |
46 | # main_window.hide()
47 |
48 |
49 | class setup_window():
50 |
51 | def close_application(self, widget, event=None):
52 | Gtk.main_quit()
53 |
54 | def __init__(self):
55 | self.vBox = Gtk.VBox(False, 0)
56 | self.vBox.show()
57 | label = Gtk.Label(label="Getting everything ready", name="Header")
58 | label.set_property("height-request", 50)
59 | self.vBox.pack_start(label, False, False, 0)
60 |
61 | hBox = Gtk.HBox(False, 0, name="install")
62 | hBox.show()
63 | self.vBox.pack_end(hBox, True, True, 0)
64 | vBox2 = Gtk.VBox(False, 0)
65 | vBox2.show()
66 | label2 = Gtk.Label(name="sideText")
67 |
68 | label2.set_markup(
69 | "This should not take too long.\n\n"
70 | "Don't turn your system off."
71 | )
72 | label2.set_justify(Gtk.Justification.LEFT)
73 | label2.set_line_wrap(True)
74 | # label2.set_max_width_chars(10)
75 | label2.set_alignment(0.5, 0.4)
76 | hBox2 = Gtk.HBox(False, 0, name="TransBox")
77 | hBox2.show()
78 | hBox.pack_start(hBox2, True, True, 0)
79 | hBox2.pack_start(label2, True, True, 0)
80 |
81 | image = Gtk.Image()
82 | image.set_from_file(f"{gbi_dir}/image/G_logo.gif")
83 | # image.set_size_request(width=256, height=256)
84 | image.show()
85 | hBox.pack_end(image, True, True, 20)
86 |
87 | def get_model(self):
88 | return self.vBox
89 |
90 |
91 | class installProgress():
92 |
93 | def __init__(self, main_window, welcome, kb, tz, adminuser):
94 | self.pbar = Gtk.ProgressBar()
95 | self.pbar.set_show_text(True)
96 | command = f'sudo {pc_sysinstall} -c {gbi_tmp}/pcinstall.cfg'
97 | thr = threading.Thread(
98 | target=read_output,
99 | args=(
100 | command,
101 | self.pbar,
102 | main_window,
103 | welcome,
104 | kb,
105 | tz,
106 | adminuser
107 | )
108 | )
109 | thr.setDaemon(True)
110 | thr.start()
111 | self.pbar.show()
112 |
113 | def getProgressBar(self):
114 | return self.pbar
115 |
--------------------------------------------------------------------------------
/src/sys_handler.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | import re
4 | import os
5 | from subprocess import Popen, run, PIPE
6 |
7 | pc_sysinstall = '/usr/local/sbin/pc-sysinstall'
8 |
9 |
10 | def replace_pattern(current, new, file):
11 | parser_file = open(file, 'r').read()
12 | parser_patched = re.sub(current, new, parser_file)
13 | save_parser_file = open(file, 'w')
14 | save_parser_file.writelines(parser_patched)
15 | save_parser_file.close()
16 |
17 |
18 | def language_dictionary():
19 | langs = Popen(f'{pc_sysinstall} query-langs', shell=True, stdin=PIPE,
20 | stdout=PIPE, universal_newlines=True,
21 | close_fds=True).stdout.readlines()
22 | dictionary = {}
23 | for line in langs:
24 | lang_list = line.rstrip()
25 | lang_name = lang_list.partition(' ')[2]
26 | lang_code = lang_list.partition(' ')[0]
27 | dictionary[lang_name] = lang_code
28 | return dictionary
29 |
30 |
31 | def localize_system(locale):
32 | slick_greeter = "/usr/local/share/xgreeters/slick-greeter.desktop"
33 | gtk_greeter = "/usr/local/share/xgreeters/lightdm-gtk-greeter.desktop"
34 | replace_pattern('lang=C', f'lang={locale}', '/etc/login.conf')
35 | replace_pattern('en_US', locale, '/etc/profile')
36 | replace_pattern('en_US', locale, '/usr/share/skel/dot.profile')
37 |
38 | if os.path.exists(slick_greeter):
39 | replace_pattern(
40 | 'Exec=slick-greeter',
41 | f'Exec=env LANG={locale}.UTF-8 slick-greeter',
42 | slick_greeter
43 | )
44 | elif os.path.exists(gtk_greeter):
45 | replace_pattern(
46 | 'Exec=lightdm-gtk-greete',
47 | f'Exec=env LANG={locale}.UTF-8 lightdm-gtk-greeter',
48 | gtk_greeter
49 | )
50 |
51 |
52 | def keyboard_dictionary():
53 | xkeyboard_layouts = Popen(f'{pc_sysinstall} xkeyboard-layouts', shell=True,
54 | stdout=PIPE,
55 | universal_newlines=True).stdout.readlines()
56 | dictionary = {}
57 | for line in xkeyboard_layouts:
58 | keyboard_list = list(filter(None, line.rstrip().split(' ')))
59 | kb_name = keyboard_list[1].strip()
60 | kb_layouts = keyboard_list[0].strip()
61 | kb_variant = None
62 | dictionary[kb_name] = {'layout': kb_layouts, 'variant': kb_variant}
63 |
64 | xkeyboard_variants = Popen(f'{pc_sysinstall} xkeyboard-variants',
65 | shell=True, stdout=PIPE,
66 | universal_newlines=True).stdout.readlines()
67 | for line in xkeyboard_variants:
68 | xkb_variant = line.rstrip()
69 | kb_name = xkb_variant.partition(':')[2].strip()
70 | keyboard_list = list(filter
71 | (None, xkb_variant.partition(':')[0].split()))
72 | kb_layouts = keyboard_list[1].strip()
73 | kb_variant = keyboard_list[0].strip()
74 | dictionary[kb_name] = {'layout': kb_layouts, 'variant': kb_variant}
75 | return dictionary
76 |
77 |
78 | def keyboard_models():
79 | xkeyboard_models = Popen(f'{pc_sysinstall} xkeyboard-models', shell=True,
80 | stdout=PIPE,
81 | universal_newlines=True).stdout.readlines()
82 | dictionary = {}
83 | for line in xkeyboard_models:
84 | kbm_name = line.rstrip().partition(' ')[2]
85 | kbm_code = line.rstrip().partition(' ')[0]
86 | dictionary[kbm_name] = kbm_code
87 | return dictionary
88 |
89 |
90 | def change_keyboard(kb_layout, kb_variant=None, kb_model=None):
91 | if kb_variant is None and kb_model is not None:
92 | run(f"setxkbmap -layout {kb_layout} -model {kb_model}", shell=True)
93 | elif kb_variant is not None and kb_model is None:
94 | run(f"setxkbmap -layout {kb_layout} -variant {kb_variant}", shell=True)
95 | elif kb_variant is not None and kb_model is not None:
96 | set_kb_cmd = f"setxkbmap -layout {kb_layout} -variant {kb_variant} " \
97 | f"-model {kb_model}"
98 | run(set_kb_cmd, shell=True)
99 | else:
100 | run(f"setxkbmap -layout {kb_layout}", shell=True)
101 |
102 |
103 | def set_keyboard(kb_layout, kb_variant=None, kb_model=None):
104 | pass
105 |
106 |
107 | def timezone_dictionary():
108 | tz_list = Popen(f'{pc_sysinstall} list-tzones', shell=True,
109 | stdout=PIPE, universal_newlines=True).stdout.readlines()
110 | city_list = []
111 | dictionary = {}
112 | last_continent = ''
113 | for zone in tz_list:
114 | zone_list = zone.partition(':')[0].rstrip().split('/')
115 | continent = zone_list[0]
116 | if continent != last_continent:
117 | city_list = []
118 | if len(zone_list) == 3:
119 | city = zone_list[1] + '/' + zone_list[2]
120 | elif len(zone_list) == 4:
121 | city = zone_list[1] + '/' + zone_list[2] + '/' + zone_list[3]
122 | else:
123 | city = zone_list[1]
124 | city_list.append(city)
125 | dictionary[continent] = city_list
126 | last_continent = continent
127 | return dictionary
128 |
129 |
130 | def set_admin_user(username, name, password, shell, homedir, hostname):
131 | # Set Root user
132 | run(f"echo '{password}' | pw usermod -n root -h 0", shell=True)
133 | cmd = f"echo '{password}' | pw useradd {username} -c {name} -h 0" \
134 | f" -s {shell} -m -d {homedir} -g wheel,operator"
135 | run(cmd, shell=True)
136 | run(f"sysrc hostname={hostname}", shell=True)
137 | run(f"hostname {hostname}", shell=True)
138 |
--------------------------------------------------------------------------------
/src/timezone.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | from gi.repository import Gtk, Gdk
4 | import os.path
5 | import os
6 | from sys_handler import timezone_dictionary
7 | # Folder use for the installer.
8 | tmp = "/tmp/.gbi/"
9 | installer = "/usr/local/lib/gbi/"
10 | if not os.path.exists(tmp):
11 | os.makedirs(tmp)
12 |
13 |
14 | time = '%stimezone' % tmp
15 | tzdictionary = timezone_dictionary()
16 |
17 | cssProvider = Gtk.CssProvider()
18 | cssProvider.load_from_path('/usr/local/lib/gbi/ghostbsd-style.css')
19 | screen = Gdk.Screen.get_default()
20 | styleContext = Gtk.StyleContext()
21 | styleContext.add_provider_for_screen(
22 | screen,
23 | cssProvider,
24 | Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
25 | )
26 |
27 |
28 | class TimeZone:
29 |
30 | def continent_columns(self, treeView):
31 | cell = Gtk.CellRendererText()
32 | column = Gtk.TreeViewColumn(None, cell, text=0)
33 | column_header = Gtk.Label('Continent')
34 | column_header.set_use_markup(True)
35 | column_header.show()
36 | column.set_widget(column_header)
37 | column.set_sort_column_id(0)
38 | treeView.append_column(column)
39 |
40 | def city_columns(self, treeView):
41 | cell = Gtk.CellRendererText()
42 | column = Gtk.TreeViewColumn(None, cell, text=0)
43 | column_header = Gtk.Label('City')
44 | column_header.set_use_markup(True)
45 | column_header.show()
46 | column.set_widget(column_header)
47 | column.set_sort_column_id(0)
48 | treeView.append_column(column)
49 |
50 | def Continent_Selection(self, tree_selection):
51 | model, treeiter = tree_selection.get_selected()
52 | self.city_store.clear()
53 | if treeiter is not None:
54 | value = model[treeiter][0]
55 | self.continent = value
56 | for line in tzdictionary[self.continent]:
57 | self.city_store.append(None, [line])
58 | self.citytreeView.set_cursor(0)
59 |
60 | def City_Selection(self, tree_selection, button3):
61 | model, treeiter = tree_selection.get_selected()
62 | if treeiter is not None:
63 | value = model[treeiter][0]
64 | self.city = value
65 | button3.set_sensitive(True)
66 | # else:
67 | # button3.set_sensitive(False)
68 |
69 | def save_selection(self):
70 | timezone = '%s/%s' % (self.continent, self.city)
71 | time_file = open(time, 'w')
72 | time_file.writelines(timezone)
73 | time_file.close()
74 | return
75 |
76 | def __init__(self, button3):
77 | self.vbox1 = Gtk.VBox(False, 0)
78 | self.vbox1.show()
79 | Title = Gtk.Label('Time Zone Selection', name="Header")
80 | Title.set_property("height-request", 50)
81 | self.vbox1.pack_start(Title, False, False, 0)
82 | box2 = Gtk.VBox(False, 10)
83 | box2.set_border_width(10)
84 | self.vbox1.pack_start(box2, True, True, 0)
85 | box2.show()
86 | table = Gtk.Table(1, 2, True)
87 | box2.pack_start(table, False, False, 0)
88 | hbox = Gtk.HBox(False, 10)
89 | hbox.set_border_width(5)
90 | box2.pack_start(hbox, True, True, 5)
91 | hbox.show()
92 |
93 | sw = Gtk.ScrolledWindow()
94 | sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
95 | sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
96 | store = Gtk.TreeStore(str)
97 | for line in tzdictionary:
98 | store.append(None, [line])
99 | self.continenttreeView = Gtk.TreeView(store)
100 | self.continenttreeView.set_model(store)
101 | self.continenttreeView.set_rules_hint(True)
102 | self.continent_columns(self.continenttreeView)
103 | self.continenttree_selection = self.continenttreeView.get_selection()
104 | self.continenttree_selection.set_mode(Gtk.SelectionMode.SINGLE)
105 | self.continenttree_selection.connect("changed",
106 | self.Continent_Selection)
107 | sw.add(self.continenttreeView)
108 | sw.show()
109 | hbox.pack_start(sw, True, True, 5)
110 |
111 | sw = Gtk.ScrolledWindow()
112 | sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
113 | sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
114 | self.city_store = Gtk.TreeStore(str)
115 | self.citytreeView = Gtk.TreeView(self.city_store)
116 | self.citytreeView.set_model(self.city_store)
117 | self.citytreeView.set_rules_hint(True)
118 | self.city_columns(self.citytreeView)
119 | tree_selection = self.citytreeView.get_selection()
120 | tree_selection.set_mode(Gtk.SelectionMode.SINGLE)
121 | tree_selection.connect("changed", self.City_Selection, button3)
122 | sw.add(self.citytreeView)
123 | sw.show()
124 | hbox.pack_start(sw, True, True, 5)
125 | return
126 |
127 | def get_model(self):
128 | self.continenttreeView.set_cursor(1)
129 | return self.vbox1
130 |
--------------------------------------------------------------------------------
/src/use_ufs.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | from gi.repository import Gtk, Gdk
4 | import os
5 | import os.path
6 | import re
7 | from partition_handler import zfs_disk_query, zfs_disk_size_query, bios_or_uefi
8 |
9 | # Folder use pr the installer.
10 | tmp = "/tmp/.gbi/"
11 | installer = "/usr/local/lib/gbi/"
12 | query = "sh /usr/local/lib/gbi/backend-query/"
13 | if not os.path.exists(tmp):
14 | os.makedirs(tmp)
15 |
16 |
17 | memory = 'sysctl hw.physmem'
18 | auto = '%sauto' % tmp
19 | disk_info = '%sdisk-info.sh' % query
20 | disk_file = '%sdisk' % tmp
21 | dslice = '%sslice' % tmp
22 | Part_label = '%sufs_config' % tmp
23 | part_schem = '%sscheme' % tmp
24 | boot_file = '%sboot' % tmp
25 | ufs_dsk_list = []
26 |
27 | cssProvider = Gtk.CssProvider()
28 | cssProvider.load_from_path('/usr/local/lib/gbi/ghostbsd-style.css')
29 | screen = Gdk.Screen.get_default()
30 | styleContext = Gtk.StyleContext()
31 | styleContext.add_provider_for_screen(
32 | screen,
33 | cssProvider,
34 | Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
35 | )
36 |
37 |
38 | # Find if pasword contain only lower case and number
39 | def lowerCase(strg, search=re.compile(r'[^a-z]').search):
40 | return not bool(search(strg))
41 |
42 |
43 | # Find if pasword contain only upper case
44 | def upperCase(strg, search=re.compile(r'[^A-Z]').search):
45 | return not bool(search(strg))
46 |
47 |
48 | # Find if pasword contain only lower case and number
49 | def lowerandNunber(strg, search=re.compile(r'[^a-z0-9]').search):
50 | return not bool(search(strg))
51 |
52 |
53 | # Find if pasword contain only upper case and number
54 | def upperandNunber(strg, search=re.compile(r'[^A-Z0-9]').search):
55 | return not bool(search(strg))
56 |
57 |
58 | # Find if pasword contain only lower and upper case and
59 | def lowerUpperCase(strg, search=re.compile(r'[^a-zA-Z]').search):
60 | return not bool(search(strg))
61 |
62 |
63 | # Find if pasword contain only lower and upper case and
64 | def lowerUpperNumber(strg, search=re.compile(r'[^a-zA-Z0-9]').search):
65 | return not bool(search(strg))
66 |
67 |
68 | # Find if password contain only lowercase, uppercase numbers and some
69 | # special character.
70 | def allCharacter(strg):
71 | search = re.compile(r'[^a-zA-Z0-9~\!@#\$%\^&\*_\+":;\'\-]').search
72 | return not bool(search(strg))
73 |
74 |
75 | class use_ufs():
76 | def save_selection(self):
77 | disk_size = int(ufs_dsk_list[0].partition('-')[2].rstrip()) - 512
78 | swap_size = int(self.swap_entry.get_text())
79 | root_size = disk_size - swap_size
80 | if self.disk_encript is True:
81 | dgeli = '.eli'
82 | else:
83 | dgeli = ''
84 | pfile = open(Part_label, 'w')
85 | disk = ufs_dsk_list[0].partition('-')[0].rstrip()
86 | pfile.writelines(f'disk0={disk}\n')
87 | if self.mirror is True:
88 | ufs_disk = ufs_dsk_list
89 | disk_len = len(ufs_disk) - 1
90 | num = 1
91 | mirror_dsk = ''
92 | while disk_len != 0:
93 | mirror_dsk += ufs_disk[num].partition('-')[0].rstrip() + " "
94 | print(mirror_dsk)
95 | num += 1
96 | disk_len -= 1
97 | pfile.writelines("mirror=%s\n" % mirror_dsk)
98 | pfile.writelines("mirrorlab=%s\n" % self.mirrorbl)
99 | else:
100 | pfile.writelines("#mirror=\n")
101 | pfile.writelines("#mirrorlab=\n")
102 | pfile.writelines('partition=ALL\n')
103 | pfile.writelines('partscheme=%s\n' % self.scheme)
104 | pfile.writelines('commitDiskPart\n\n')
105 | if bios_or_uefi() == "UEFI":
106 | root_size = root_size - 100
107 | else:
108 | root_size = root_size - 1
109 | # adding zero to use remaining space
110 | zfsPart = f'disk0-part={self.fs}{dgeli} {root_size} /\n'
111 | pfile.writelines(zfsPart)
112 | if swap_size != 0:
113 | pfile.writelines('disk0-part=SWAP 0 none\n')
114 | if self.disk_encript is True:
115 | pfile.writelines('encpass=%s\n' % self.password.get_text())
116 | else:
117 | pfile.writelines('#encpass=None\n')
118 | pfile.writelines('commitDiskLabel\n')
119 | pfile.close()
120 |
121 | def sheme_selection(self, combobox):
122 | model = combobox.get_model()
123 | index = combobox.get_active()
124 | data = model[index][0]
125 | self.scheme = data
126 |
127 | def mirror_selection(self, combobox):
128 | model = combobox.get_model()
129 | index = combobox.get_active()
130 | data = model[index][0]
131 | self.mirrorbl = data
132 |
133 | def on_check_mirror(self, widget):
134 | if widget.get_active():
135 | self.mirrorbl_box.set_sensitive(True)
136 | self.mirror = True
137 | else:
138 | self.mirrorbl_box.set_sensitive(False)
139 | self.mirror = False
140 | if self.mirror is False:
141 | self.mirrorTips.set_text("Please select one drive")
142 | if len(ufs_dsk_list) != 1:
143 | self.button3.set_sensitive(False)
144 | else:
145 | self.button3.set_sensitive(True)
146 | elif self.mirror is True:
147 | self.mirrorTips.set_text("Please select 2 drive for mirroring")
148 | if len(ufs_dsk_list) > 1:
149 | self.button3.set_sensitive(True)
150 | else:
151 | self.button3.set_sensitive(False)
152 |
153 | def on_check(self, widget):
154 | if widget.get_active():
155 | self.zfs_four_k = True
156 | else:
157 | self.zfs_four_k = False
158 |
159 | def on_check_encrypt(self, widget):
160 | if widget.get_active():
161 | self.password.set_sensitive(True)
162 | self.repassword.set_sensitive(True)
163 | self.disk_encript = True
164 | # self.swap_encrypt_check.set_active(True)
165 | self.button3.set_sensitive(False)
166 | else:
167 | self.password.set_sensitive(False)
168 | self.repassword.set_sensitive(False)
169 | self.disk_encript = False
170 | # self.swap_encrypt_check.set_active(False)
171 | if self.mirror is False:
172 | if len(ufs_dsk_list) != 1:
173 | self.button3.set_sensitive(False)
174 | else:
175 | self.button3.set_sensitive(True)
176 | elif self.mirror is True:
177 | if len(ufs_dsk_list) > 1:
178 | self.button3.set_sensitive(True)
179 | else:
180 | self.button3.set_sensitive(False)
181 |
182 | def on_check_swap_encrypt(self, widget):
183 | if widget.get_active():
184 | self.swap_encrypt = True
185 | else:
186 | self.swap_encrypt = False
187 |
188 | def on_check_swap_mirror(self, widget):
189 | if widget.get_active():
190 | self.swap_mirror = True
191 | else:
192 | self.swap_mirror = False
193 |
194 | def chosefs(self, combobox):
195 | model = combobox.get_model()
196 | index = combobox.get_active()
197 | data = model[index][0]
198 | self.fs = data
199 |
200 | def __init__(self, button3):
201 | self.button3 = button3
202 | self.vbox1 = Gtk.VBox(False, 0)
203 | self.vbox1.show()
204 | # Title
205 | Title = Gtk.Label("UFS Full Disk Configuration", name="Header")
206 | Title.set_property("height-request", 50)
207 | self.vbox1.pack_start(Title, False, False, 0)
208 | # Chose disk
209 | sw = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
210 | sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
211 | sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
212 | store = Gtk.TreeStore(str, str, str, 'gboolean')
213 | for disk in zfs_disk_query():
214 | dsk = disk.partition(':')[0].rstrip()
215 | dsk_name = disk.partition(':')[2].rstrip()
216 | dsk_size = zfs_disk_size_query(dsk).rstrip()
217 | store.append(None, [dsk, dsk_size, dsk_name, False])
218 | treeView = Gtk.TreeView(store)
219 | treeView.set_model(store)
220 | treeView.set_rules_hint(True)
221 | self.check_cell = Gtk.CellRendererToggle()
222 | self.check_cell.set_property('activatable', True)
223 | self.check_cell.connect('toggled', self.col1_toggled_cb, store)
224 | cell = Gtk.CellRendererText()
225 | column = Gtk.TreeViewColumn(None, cell, text=0)
226 | column_header = Gtk.Label('Disk')
227 | column_header.set_use_markup(True)
228 | column_header.show()
229 | column.set_widget(column_header)
230 | column.set_sort_column_id(0)
231 | cell2 = Gtk.CellRendererText()
232 | column2 = Gtk.TreeViewColumn(None, cell2, text=0)
233 | column_header2 = Gtk.Label('Size(MB)')
234 | column_header2.set_use_markup(True)
235 | column_header2.show()
236 | column2.set_widget(column_header2)
237 | cell3 = Gtk.CellRendererText()
238 | column3 = Gtk.TreeViewColumn(None, cell3, text=0)
239 | column_header3 = Gtk.Label('Name')
240 | column_header3.set_use_markup(True)
241 | column_header3.show()
242 | column3.set_widget(column_header3)
243 | column1 = Gtk.TreeViewColumn("Check", self.check_cell)
244 | column1.add_attribute(self.check_cell, "active", 3)
245 | column.set_attributes(cell, text=0)
246 | column2.set_attributes(cell2, text=1)
247 | column3.set_attributes(cell3, text=2)
248 | treeView.append_column(column1)
249 | treeView.append_column(column)
250 | treeView.append_column(column2)
251 | treeView.append_column(column3)
252 | tree_selection = treeView.get_selection()
253 | tree_selection.set_mode(Gtk.SelectionMode.SINGLE)
254 | sw.add(treeView)
255 | sw.show()
256 | self.mirrorTips = Gtk.Label('Please select one drive')
257 | self.mirrorTips.set_justify(Gtk.Justification.LEFT)
258 | self.mirrorTips.set_alignment(0.01, 0.5)
259 | self.mirror = False
260 | mirror_check = Gtk.CheckButton('Disk Mirror')
261 | mirror_check.connect("toggled", self.on_check_mirror)
262 | self.mirrorbl_box = Gtk.ComboBoxText()
263 | self.mirrorbl_box.append_text("load")
264 | self.mirrorbl_box.append_text("prefer")
265 | self.mirrorbl_box.append_text("round-robin")
266 | self.mirrorbl_box.append_text("split")
267 | self.mirrorbl_box.connect('changed', self.mirror_selection)
268 | self.mirrorbl_box.set_active(0)
269 | self.mirrorbl_box.set_sensitive(False)
270 | self.mirrorbl = 'load'
271 | # Creating MBR or GPT drive
272 | label = Gtk.Label('Partition Scheme')
273 | label.set_use_markup(True)
274 | # Adding a combo box to selecting MBR or GPT sheme.
275 | self.scheme = 'GPT'
276 | shemebox = Gtk.ComboBoxText()
277 | shemebox.append_text("GPT")
278 | shemebox.append_text("MBR")
279 | shemebox.connect('changed', self.sheme_selection)
280 | shemebox.set_active(0)
281 | if bios_or_uefi() == "UEFI":
282 | shemebox.set_sensitive(False)
283 | else:
284 | shemebox.set_sensitive(True)
285 | # Swap Size
286 | # ram = Popen(memory, shell=True, stdin=PIPE, stdout=PIPE,
287 | # stderr=STDOUT, universal_newlines=True, close_fds=True)
288 | # mem = ram.stdout.read()
289 | swap = 2048
290 | swp_size_label = Gtk.Label('Swap Size(MB)')
291 | swp_size_label.set_use_markup(True)
292 | self.swap_entry = Gtk.Entry()
293 | self.swap_entry.set_text(str(swap))
294 | self.swap_entry.connect('changed', self.digit_only)
295 | # Swap encription
296 | self.swap_encrypt = False
297 | self.swap_encrypt_check = Gtk.CheckButton("Encrypt Swap")
298 | self.swap_encrypt_check.connect("toggled", self.on_check_swap_encrypt)
299 | # Swap mirror
300 | self.swap_mirror = False
301 | swap_mirror_check = Gtk.CheckButton("Mirror Swap")
302 | swap_mirror_check.connect("toggled", self.on_check_swap_mirror)
303 | # GELI Disk encription
304 | self.disk_encript = False
305 | encrypt_check = Gtk.CheckButton("Encrypt Disk")
306 | encrypt_check.connect("toggled", self.on_check_encrypt)
307 | encrypt_check.set_sensitive(True)
308 | # password
309 | self.passwd_label = Gtk.Label("Password")
310 | self.password = Gtk.Entry()
311 | self.password.set_sensitive(False)
312 | self.password.set_visibility(False)
313 | self.password.connect("changed", self.passwdstrength)
314 | self.strenght_label = Gtk.Label()
315 | self.strenght_label.set_alignment(0.1, 0.5)
316 | self.vpasswd_label = Gtk.Label("Verify it")
317 | self.repassword = Gtk.Entry()
318 | self.repassword.set_sensitive(False)
319 | self.repassword.set_visibility(False)
320 | self.repassword.connect("changed", self.passwdVerification)
321 | # set image for password matching
322 | fslabel = Gtk.Label("File System:")
323 | self.fstype = Gtk.ComboBoxText()
324 | self.fstype.append_text('UFS')
325 | self.fstype.append_text('UFS+S')
326 | self.fstype.append_text('UFS+J')
327 | self.fstype.append_text('UFS+SUJ')
328 | self.fstype.set_active(3)
329 | self.fstype.connect("changed", self.chosefs)
330 | self.fs = "UFS+SUJ"
331 | grid = Gtk.Grid()
332 | grid.set_row_spacing(10)
333 | # grid.set_column_homogeneous(True)
334 | # grid.set_row_homogeneous(True)
335 | grid.attach(Title, 0, 0, 9, 2)
336 | grid.attach(mirror_check, 0, 2, 1, 1)
337 | grid.attach(self.mirrorbl_box, 1, 2, 1, 1)
338 | grid.attach(label, 0, 9, 2, 1)
339 | grid.attach(shemebox, 2, 9, 1, 1)
340 | grid.attach(self.mirrorTips, 1, 3, 8, 1)
341 | grid.attach(sw, 0, 4, 9, 4)
342 | grid.attach(fslabel, 5, 9, 2, 1)
343 | grid.attach(self.fstype, 7, 9, 1, 1)
344 | grid.attach(swp_size_label, 5, 2, 2, 1)
345 | grid.attach(self.swap_entry, 7, 2, 1, 1)
346 | # grid.attach(self.swap_encrypt_check, 9, 15, 11, 12)
347 | # grid.attach(swap_mirror_check, 9, 15, 11, 12)
348 | # grid.attach(encrypt_check, 1, 9, 2, 1)
349 | # grid.attach(self.passwd_label, 1, 10, 1, 1)
350 | # grid.attach(self.password, 2, 10, 2, 1)
351 | # grid.attach(self.strenght_label, 4, 10, 2, 1)
352 | # grid.attach(self.vpasswd_label, 1, 11, 1, 1)
353 | # grid.attach(self.repassword, 2, 11, 2, 1)
354 | # grid.attach(self.img, 4, 11, 2, 1)
355 | self.vbox1.pack_start(grid, True, True, 10)
356 | return
357 |
358 | def get_model(self):
359 | del ufs_dsk_list[:]
360 | return self.vbox1
361 |
362 | def digit_only(self, *args):
363 | text = self.swap_entry.get_text().strip()
364 | digit = ''.join([i for i in text if i in '0123456789'])
365 | self.swap_entry.set_text(digit)
366 |
367 | def col1_toggled_cb(self, cell, path, model):
368 | model[path][3] = not model[path][3]
369 | if model[path][3] is False:
370 | ufs_dsk_list.remove(model[path][0] + "-" + model[path][1])
371 | if self.mirror is False:
372 | if len(ufs_dsk_list) != 1:
373 | self.button3.set_sensitive(False)
374 | else:
375 | self.button3.set_sensitive(True)
376 | elif self.mirror is True:
377 | if len(ufs_dsk_list) > 1:
378 | self.button3.set_sensitive(True)
379 | else:
380 | self.button3.set_sensitive(False)
381 | else:
382 | ufs_dsk_list.extend([model[path][0] + "-" + model[path][1]])
383 | if self.mirror is False:
384 | if len(ufs_dsk_list) != 1:
385 | self.button3.set_sensitive(False)
386 | else:
387 | self.button3.set_sensitive(True)
388 | elif self.mirror is True:
389 | if len(ufs_dsk_list) > 1:
390 | self.button3.set_sensitive(True)
391 | else:
392 | self.button3.set_sensitive(False)
393 | print(ufs_dsk_list)
394 | return
395 |
396 | def passwdstrength(self, widget):
397 | passwd = self.password.get_text()
398 | if len(passwd) <= 4:
399 | self.strenght_label.set_text("Super Weak")
400 | elif len(passwd) <= 8:
401 | if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
402 | self.strenght_label.set_text("Super Weak")
403 | elif lowerandNunber(passwd):
404 | self.strenght_label.set_text("Very Weak")
405 | elif upperandNunber(passwd):
406 | self.strenght_label.set_text("Very Weak")
407 | elif lowerUpperCase(passwd):
408 | self.strenght_label.set_text("Very Weak")
409 | elif lowerUpperNumber(passwd):
410 | self.strenght_label.set_text("Fairly Weak")
411 | elif allCharacter(passwd):
412 | self.strenght_label.set_text("Weak")
413 | elif len(passwd) <= 12:
414 | if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
415 | self.strenght_label.set_text("Very Weak")
416 | elif lowerandNunber(passwd):
417 | self.strenght_label.set_text("Fairly Weak")
418 | elif upperandNunber(passwd):
419 | self.strenght_label.set_text("Fairly Weak")
420 | elif lowerUpperCase(passwd):
421 | self.strenght_label.set_text("Fairly Weak")
422 | elif lowerUpperNumber(passwd):
423 | self.strenght_label.set_text("Weak")
424 | elif allCharacter(passwd):
425 | self.strenght_label.set_text("Strong")
426 | elif len(passwd) <= 16:
427 | if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
428 | self.strenght_label.set_text("Fairly Weak")
429 | elif lowerandNunber(passwd):
430 | self.strenght_label.set_text("Weak")
431 | elif upperandNunber(passwd):
432 | self.strenght_label.set_text("Weak")
433 | elif lowerUpperCase(passwd):
434 | self.strenght_label.set_text("Weak")
435 | elif lowerUpperNumber(passwd):
436 | self.strenght_label.set_text("Strong")
437 | elif allCharacter(passwd):
438 | self.strenght_label.set_text("Fairly Strong")
439 | elif len(passwd) <= 20:
440 | if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
441 | self.strenght_label.set_text("Weak")
442 | elif lowerandNunber(passwd):
443 | self.strenght_label.set_text("Strong")
444 | elif upperandNunber(passwd):
445 | self.strenght_label.set_text("Strong")
446 | elif lowerUpperCase(passwd):
447 | self.strenght_label.set_text("Strong")
448 | elif lowerUpperNumber(passwd):
449 | self.strenght_label.set_text("Fairly Strong")
450 | elif allCharacter(passwd):
451 | self.strenght_label.set_text("Very Strong")
452 | elif len(passwd) <= 24:
453 | if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
454 | self.strenght_label.set_text("Strong")
455 | elif lowerandNunber(passwd):
456 | self.strenght_label.set_text("Fairly Strong")
457 | elif upperandNunber(passwd):
458 | self.strenght_label.set_text("Fairly Strong")
459 | elif lowerUpperCase(passwd):
460 | self.strenght_label.set_text("Fairly Strong")
461 | elif lowerUpperNumber(passwd):
462 | self.strenght_label.set_text("Very Strong")
463 | elif allCharacter(passwd):
464 | self.strenght_label.set_text("Super Strong")
465 | elif len(passwd) > 24:
466 | if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
467 | self.strenght_label.set_text("Fairly Strong")
468 | else:
469 | self.strenght_label.set_text("Super Strong")
470 |
471 | def passwdVerification(self, widget):
472 | if self.password.get_text() == self.repassword.get_text():
473 | self.img.set_from_stock(Gtk.STOCK_YES, 5)
474 | if self.mirror == "none":
475 | if len(ufs_dsk_list) != 1:
476 | self.button3.set_sensitive(False)
477 | else:
478 | self.button3.set_sensitive(True)
479 | elif self.mirror == "mirror":
480 | if len(ufs_dsk_list) > 1:
481 | self.button3.set_sensitive(True)
482 | else:
483 | self.button3.set_sensitive(False)
484 | else:
485 | self.img.set_from_stock(Gtk.STOCK_NO, 5)
486 | self.button3.set_sensitive(False)
487 |
--------------------------------------------------------------------------------
/src/use_zfs.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | from gi.repository import Gtk, Gdk
4 | import os
5 | import re
6 | from gbi_common import zfs_datasets, be_name
7 | from partition_handler import (
8 | zfs_disk_query,
9 | zfs_disk_size_query,
10 | bios_or_uefi
11 | )
12 |
13 |
14 | # Folder use pr the installer.
15 | tmp = "/tmp/.gbi/"
16 | installer = "/usr/local/lib/gbi/"
17 | logo = f"{installer}image/logo.png"
18 | query = "sh /usr/local/lib/gbi/backend-query/"
19 | if not os.path.exists(tmp):
20 | os.makedirs(tmp)
21 |
22 | memory = 'sysctl hw.physmem'
23 | auto = '%sauto' % tmp
24 | disk_info = '%sdisk-info.sh' % query
25 | disk_file = '%sdisk' % tmp
26 | dslice = '%sslice' % tmp
27 | Part_label = '%szfs_config' % tmp
28 | part_schem = '%sscheme' % tmp
29 | boot_file = '%sboot' % tmp
30 |
31 | cssProvider = Gtk.CssProvider()
32 | cssProvider.load_from_path('/usr/local/lib/gbi/ghostbsd-style.css')
33 | screen = Gdk.Screen.get_default()
34 | styleContext = Gtk.StyleContext()
35 | styleContext.add_provider_for_screen(
36 | screen,
37 | cssProvider,
38 | Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
39 | )
40 |
41 |
42 | # Find if password contain only lower case and number
43 | def lowerCase(strg, search=re.compile(r'[^a-z]').search):
44 | return not bool(search(strg))
45 |
46 |
47 | # Find if password contain only upper case
48 | def upperCase(strg, search=re.compile(r'[^A-Z]').search):
49 | return not bool(search(strg))
50 |
51 |
52 | # Find if password contain only lower case and number
53 | def lowerandNunber(strg, search=re.compile(r'[^a-z0-9]').search):
54 | return not bool(search(strg))
55 |
56 |
57 | # Find if password contain only upper case and number
58 | def upperandNunber(strg, search=re.compile(r'[^A-Z0-9]').search):
59 | return not bool(search(strg))
60 |
61 |
62 | # Find if password contain only lower and upper case and
63 | def lowerUpperCase(strg, search=re.compile(r'[^a-zA-Z]').search):
64 | return not bool(search(strg))
65 |
66 |
67 | # Find if password contain only lower and upper case and
68 | def lowerUpperNumber(strg, search=re.compile(r'[^a-zA-Z0-9]').search):
69 | return not bool(search(strg))
70 |
71 |
72 | # Find if password contain only lowercase, uppercase numbers
73 | # and some special character.
74 | def allCharacter(strg):
75 | search = re.compile(r'[^a-zA-Z0-9~\!@#\$%\^&\*_\+":;\'\-]').search
76 | return not bool(search(strg))
77 |
78 |
79 | class ZFS:
80 | zfs_disk_list = []
81 |
82 | def save_selection(self):
83 | SIZE = int(self.zfs_disk_list[0].partition('-')[2].rstrip()) - 512
84 | SWAP = int(self.swap_entry.get_text())
85 | ZFS_NUM = SIZE - SWAP
86 | if self.disk_encript is True:
87 | dgeli = '.eli'
88 | else:
89 | dgeli = ''
90 | pfile = open(Part_label, 'w')
91 | if self.zpool is True:
92 | pfile.writelines("zpoolName=%s\n" % self.pool.get_text())
93 | else:
94 | pfile.writelines("#zpoolName=None\n")
95 | pfile.writelines(f"beName={be_name}\n")
96 | if self.zfs_four_k is True:
97 | pfile.writelines('ashift=12\n\n')
98 | else:
99 | pfile.writelines('ashift=9\n\n')
100 | disk = self.zfs_disk_list[0].partition('-')[0].rstrip()
101 | pfile.writelines(f'disk0={disk}\n')
102 | pfile.writelines('partition=ALL\n')
103 | pfile.writelines('partscheme=%s\n' % self.scheme)
104 | pfile.writelines('commitDiskPart\n\n')
105 | if self.poolType == 'none':
106 | pool_disk = '\n'
107 | else:
108 | ZFS_disk = self.zfs_disk_list
109 | disk_len = len(ZFS_disk) - 1
110 | num = 1
111 | mirror_dsk = ''
112 | while disk_len != 0:
113 | mirror_dsk += ' ' + ZFS_disk[num].partition('-')[0].rstrip()
114 | print(mirror_dsk)
115 | num += 1
116 | disk_len -= 1
117 | pool_disk = ' (%s:%s)\n' % (self.poolType, mirror_dsk)
118 | if bios_or_uefi() == "UEFI":
119 | ZFS_NUM = ZFS_NUM - 100
120 | else:
121 | ZFS_NUM = ZFS_NUM - 1
122 | # adding zero to use remaining space
123 | zfs_part = f'disk0-part=ZFS{dgeli} {ZFS_NUM} {zfs_datasets}{pool_disk}'
124 | pfile.writelines(zfs_part)
125 | if SWAP != 0:
126 | pfile.writelines('disk0-part=SWAP 0 none\n')
127 | if self.disk_encript is True:
128 | pfile.writelines('encpass=%s\n' % self.password.get_text())
129 | else:
130 | pfile.writelines('#encpass=None\n')
131 | pfile.writelines('commitDiskLabel\n')
132 | pfile.close()
133 |
134 | def sheme_selection(self, combobox):
135 | model = combobox.get_model()
136 | index = combobox.get_active()
137 | data = model[index][0]
138 | self.scheme = data.partition(':')[0]
139 |
140 | def mirror_selection(self, combobox):
141 | model = combobox.get_model()
142 | index = combobox.get_active()
143 | mirror_message = " (select the smallest disk first)"
144 | data = model[index][0]
145 | self.mirror = data
146 | if self.mirror == "single disk":
147 | self.poolType = 'none'
148 | self.mirrorTips.set_text("Please select one drive")
149 | if len(self.zfs_disk_list) != 1:
150 | self.button3.set_sensitive(False)
151 | else:
152 | self.button3.set_sensitive(True)
153 | elif self.mirror == "2 disk mirror":
154 | self.poolType = 'mirror'
155 | mir_msg1 = f"Please select 2 drive for mirroring{mirror_message}"
156 | self.mirrorTips.set_text(mir_msg1)
157 | if len(self.zfs_disk_list) == 2:
158 | self.button3.set_sensitive(True)
159 | else:
160 | self.button3.set_sensitive(False)
161 | elif self.mirror == "3 disk raidz1":
162 | self.poolType = 'raidz1'
163 | self.mirrorTips.set_text(f"Please select 3 drive for "
164 | f"raidz1{mirror_message}")
165 | if len(self.zfs_disk_list) == 3:
166 | self.button3.set_sensitive(True)
167 | else:
168 | self.button3.set_sensitive(False)
169 | elif self.mirror == "4 disk raidz2":
170 | self.poolType = 'raidz2'
171 | self.mirrorTips.set_text(f"Please select 4 drive for "
172 | f"raidz2{mirror_message}")
173 | if len(self.zfs_disk_list) == 4:
174 | self.button3.set_sensitive(True)
175 | else:
176 | self.button3.set_sensitive(False)
177 | elif self.mirror == "5 disk raidz3":
178 | self.poolType = 'raidz3'
179 | self.mirrorTips.set_text("Please select 5 drive for "
180 | f"raidz3{mirror_message}")
181 | if len(self.zfs_disk_list) == 5:
182 | self.button3.set_sensitive(True)
183 | else:
184 | self.button3.set_sensitive(False)
185 | elif self.mirror == "2+ disk stripe":
186 | self.poolType = 'stripe'
187 | self.mirrorTips.set_text("Please select 2 or more drive for "
188 | f"stripe{mirror_message}")
189 | if len(self.zfs_disk_list) >= 2:
190 | self.button3.set_sensitive(True)
191 | else:
192 | self.button3.set_sensitive(False)
193 |
194 | def on_check_poll(self, widget):
195 | if widget.get_active():
196 | self.pool.set_sensitive(True)
197 | self.zpool = True
198 | else:
199 | self.pool.set_sensitive(False)
200 | self.zpool = False
201 |
202 | def on_check(self, widget):
203 | if widget.get_active():
204 | self.zfs_four_k = True
205 | else:
206 | self.zfs_four_k = False
207 |
208 | def on_check_encrypt(self, widget):
209 | if widget.get_active():
210 | self.password.set_sensitive(True)
211 | self.repassword.set_sensitive(True)
212 | self.disk_encript = True
213 | # self.swap_encrypt_check.set_active(True)
214 | self.button3.set_sensitive(False)
215 | else:
216 | self.password.set_sensitive(False)
217 | self.repassword.set_sensitive(False)
218 | self.disk_encript = False
219 | # self.swap_encrypt_check.set_active(False)
220 | if self.mirror == "single disk":
221 | if len(self.zfs_disk_list) != 1:
222 | self.button3.set_sensitive(False)
223 | else:
224 | self.button3.set_sensitive(True)
225 | elif self.mirror == "2 disk mirror":
226 | if len(self.zfs_disk_list) == 2:
227 | self.button3.set_sensitive(True)
228 | else:
229 | self.button3.set_sensitive(False)
230 | elif self.mirror == "3 disk raidz1":
231 | if len(self.zfs_disk_list) == 3:
232 | self.button3.set_sensitive(True)
233 | else:
234 | self.button3.set_sensitive(False)
235 | elif self.mirror == "4 disk raidz2":
236 | if len(self.zfs_disk_list) == 4:
237 | self.button3.set_sensitive(True)
238 | else:
239 | self.button3.set_sensitive(False)
240 | elif self.mirror == "5 disk raidz3":
241 | if len(self.zfs_disk_list) == 5:
242 | self.button3.set_sensitive(True)
243 | else:
244 | self.button3.set_sensitive(False)
245 | elif self.mirror == "2+ disk stripe":
246 | if len(self.zfs_disk_list) >= 2:
247 | self.button3.set_sensitive(True)
248 | else:
249 | self.button3.set_sensitive(False)
250 |
251 | def on_check_swap_encrypt(self, widget):
252 | if widget.get_active():
253 | self.swap_encrypt = True
254 | else:
255 | self.swap_encrypt = False
256 |
257 | def on_check_swap_mirror(self, widget):
258 | if widget.get_active():
259 | self.swap_mirror = True
260 | else:
261 | self.swap_mirror = False
262 |
263 | def __init__(self, button3):
264 | self.button3 = button3
265 | self.vbox1 = Gtk.VBox(False, 0)
266 | self.vbox1.show()
267 | # Title
268 | Title = Gtk.Label("ZFS Configuration", name="Header")
269 | Title.set_property("height-request", 50)
270 | self.vbox1.pack_start(Title, False, False, 0)
271 | # Chose disk
272 | sw = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
273 | sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
274 | sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
275 | self.store = Gtk.TreeStore(str, str, str, 'gboolean')
276 | for disk in zfs_disk_query():
277 | dsk = disk.partition(':')[0].rstrip()
278 | if dsk.startswith("da"):
279 | continue
280 | dsk_name = disk.partition(':')[2].rstrip()
281 | dsk_size = zfs_disk_size_query(dsk).rstrip()
282 | self.store.append(None, [dsk, dsk_size, dsk_name, False])
283 | treeView = Gtk.TreeView(self.store)
284 | treeView.set_model(self.store)
285 | treeView.set_rules_hint(True)
286 | self.check_cell = Gtk.CellRendererToggle()
287 | self.check_cell.set_property('activatable', True)
288 | self.check_cell.connect('toggled', self.col1_toggled_cb, self.store)
289 | cell = Gtk.CellRendererText()
290 | column = Gtk.TreeViewColumn(None, cell, text=0)
291 | column_header = Gtk.Label('Disk')
292 | column_header.set_use_markup(True)
293 | column_header.show()
294 | column.set_widget(column_header)
295 | column.set_sort_column_id(0)
296 | cell2 = Gtk.CellRendererText()
297 | column2 = Gtk.TreeViewColumn(None, cell2, text=0)
298 | column_header2 = Gtk.Label('Size(MB)')
299 | column_header2.set_use_markup(True)
300 | column_header2.show()
301 | column2.set_widget(column_header2)
302 | cell3 = Gtk.CellRendererText()
303 | column3 = Gtk.TreeViewColumn(None, cell3, text=0)
304 | column_header3 = Gtk.Label('Name')
305 | column_header3.set_use_markup(True)
306 | column_header3.show()
307 | column3.set_widget(column_header3)
308 | column1 = Gtk.TreeViewColumn("Check", self.check_cell)
309 | column1.add_attribute(self.check_cell, "active", 3)
310 | column.set_attributes(cell, text=0)
311 | column2.set_attributes(cell2, text=1)
312 | column3.set_attributes(cell3, text=2)
313 | treeView.append_column(column1)
314 | treeView.append_column(column)
315 | treeView.append_column(column2)
316 | treeView.append_column(column3)
317 | tree_selection = treeView.get_selection()
318 | tree_selection.set_mode(Gtk.SelectionMode.SINGLE)
319 | sw.add(treeView)
320 | sw.show()
321 | self.mirrorTips = Gtk.Label('Please select one drive')
322 | self.mirrorTips.set_justify(Gtk.Justification.LEFT)
323 | self.mirrorTips.set_alignment(0.01, 0.5)
324 | # Mirror, raidz and stripe
325 | self.mirror = 'none'
326 | mirror_label = Gtk.Label('Pool Type')
327 | mirror_label.set_use_markup(True)
328 | mirror_box = Gtk.ComboBoxText()
329 | mirror_box.append_text("single disk")
330 | mirror_box.append_text("2 disk mirror")
331 | mirror_box.append_text("3 disk raidz1")
332 | mirror_box.append_text("4 disk raidz2")
333 | mirror_box.append_text("5 disk raidz3")
334 | mirror_box.append_text("2+ disk stripe")
335 | mirror_box.connect('changed', self.mirror_selection)
336 | mirror_box.set_active(0)
337 |
338 | # Pool Name
339 | self.zpool = False
340 | pool_check = Gtk.CheckButton('Pool Name')
341 | pool_check.connect("toggled", self.on_check_poll)
342 | self.pool = Gtk.Entry()
343 | self.pool.set_text('zroot')
344 | self.pool.set_sensitive(False)
345 | # Creating MBR or GPT drive
346 | scheme_label = Gtk.Label('Partition Scheme')
347 | scheme_label.set_use_markup(True)
348 | # Adding a combo box to selecting MBR or GPT sheme.
349 | self.scheme = 'GPT'
350 | shemebox = Gtk.ComboBoxText()
351 | shemebox.append_text("GPT")
352 | shemebox.append_text("MBR")
353 | shemebox.connect('changed', self.sheme_selection)
354 | shemebox.set_active(0)
355 | if bios_or_uefi() == "UEFI":
356 | shemebox.set_sensitive(False)
357 | else:
358 | shemebox.set_sensitive(True)
359 | # Force 4k Sectors
360 | self.zfs_four_k = "True"
361 | zfs4kcheck = Gtk.CheckButton("Force ZFS 4k block size")
362 | zfs4kcheck.connect("toggled", self.on_check)
363 | zfs4kcheck.set_active(True)
364 | # Swap Size
365 | # ram = Popen(memory, shell=True, stdin=PIPE, stdout=PIPE,
366 | # stderr=STDOUT, universal_newlines=True, close_fds=True)
367 | # mem = ram.stdout.read()
368 | swap = 2048
369 | swp_size_label = Gtk.Label('Swap Size(MB)')
370 | swp_size_label.set_use_markup(True)
371 | self.swap_entry = Gtk.Entry()
372 | self.swap_entry.set_text(str(swap))
373 | self.swap_entry.connect('changed', self.digit_only)
374 | # Swap encription
375 | self.swap_encrypt = False
376 | self.swap_encrypt_check = Gtk.CheckButton("Encrypt Swap")
377 | self.swap_encrypt_check.connect("toggled", self.on_check_swap_encrypt)
378 | # Swap mirror
379 | self.swap_mirror = False
380 | swap_mirror_check = Gtk.CheckButton("Mirror Swap")
381 | swap_mirror_check.connect("toggled", self.on_check_swap_mirror)
382 | # GELI Disk encription
383 | self.disk_encript = False
384 | encrypt_check = Gtk.CheckButton("Encrypt Disk")
385 | encrypt_check.connect("toggled", self.on_check_encrypt)
386 | encrypt_check.set_sensitive(True)
387 | # password
388 | self.passwd_label = Gtk.Label("Password")
389 | self.password = Gtk.Entry()
390 | self.password.set_sensitive(False)
391 | self.password.set_visibility(False)
392 | self.password.connect("changed", self.passwdstrength)
393 | self.strenght_label = Gtk.Label()
394 | self.strenght_label.set_alignment(0.1, 0.5)
395 | self.vpasswd_label = Gtk.Label("Verify it")
396 | self.repassword = Gtk.Entry()
397 | self.repassword.set_sensitive(False)
398 | self.repassword.set_visibility(False)
399 | self.repassword.connect("changed", self.passwdVerification)
400 | # set image for password matching
401 | self.img = Gtk.Image()
402 | self.img.set_alignment(0.2, 0.5)
403 | # table = Gtk.Table(12, 12, True)
404 | grid = Gtk.Grid()
405 | grid.set_row_spacing(10)
406 | # grid.set_column_homogeneous(True)
407 | # grid.set_row_homogeneous(True)
408 | # grid.attach(Title, 1, 1, 10, 1)
409 | grid.attach(mirror_label, 1, 2, 1, 1)
410 | grid.attach(mirror_box, 2, 2, 1, 1)
411 | grid.attach(pool_check, 7, 2, 2, 1)
412 | grid.attach(self.pool, 9, 2, 2, 1)
413 | grid.attach(self.mirrorTips, 1, 3, 8, 1)
414 | grid.attach(zfs4kcheck, 9, 3, 2, 1)
415 | grid.attach(sw, 1, 4, 10, 3)
416 | # grid.attach(scheme_label, 1, 9, 1, 1)
417 | # grid.attach(shemebox, 2, 9, 1, 1)
418 | grid.attach(swp_size_label, 9, 9, 1, 1)
419 | grid.attach(self.swap_entry, 10, 9, 1, 1)
420 | # grid.attach(self.swap_encrypt_check, 9, 15, 11, 12)
421 | # grid.attach(swap_mirror_check, 9, 15, 11, 12)
422 | # grid.attach(encrypt_check, 2, 8, 2, 1)
423 | # grid.attach(self.passwd_label, 1, 9, 1, 1)
424 | # grid.attach(self.password, 2, 9, 2, 1)
425 | # grid.attach(self.strenght_label, 4, 9, 2, 1)
426 | # grid.attach(self.vpasswd_label, 1, 10, 1, 1)
427 | # grid.attach(self.repassword, 2, 10, 2, 1)
428 | # grid.attach(self.img, 4, 10, 2, 1)
429 | self.vbox1.pack_start(grid, True, True, 10)
430 | return
431 |
432 | def get_model(self):
433 | return self.vbox1
434 |
435 | def digit_only(self, *args):
436 | text = self.swap_entry.get_text().strip()
437 | digit = ''.join([i for i in text if i in '0123456789'])
438 | self.swap_entry.set_text(digit)
439 |
440 | def check_if_small_disk(self, size):
441 | if len(self.zfs_disk_list) != 0:
442 | for line in self.zfs_disk_list:
443 | if int(line.partition('-')[2]) > int(size):
444 | returns = True
445 | break
446 | else:
447 | returns = False
448 | else:
449 | returns = False
450 | return returns
451 |
452 | def col1_toggled_cb(self, cell, path, model):
453 | model[path][3] = not model[path][3]
454 | if model[path][3] is False:
455 | self.zfs_disk_list.remove(model[path][0] + "-" + model[path][1])
456 | if self.mirror == "single disk":
457 | if len(self.zfs_disk_list) != 1:
458 | self.button3.set_sensitive(False)
459 | else:
460 | self.button3.set_sensitive(True)
461 | elif self.mirror == "2 disk mirror":
462 | if len(self.zfs_disk_list) == 2:
463 | self.button3.set_sensitive(True)
464 | else:
465 | self.button3.set_sensitive(False)
466 | elif self.mirror == "3 disk raidz1":
467 | if len(self.zfs_disk_list) == 3:
468 | self.button3.set_sensitive(True)
469 | else:
470 | self.button3.set_sensitive(False)
471 | elif self.mirror == "4 disk raidz2":
472 | if len(self.zfs_disk_list) == 4:
473 | self.button3.set_sensitive(True)
474 | else:
475 | self.button3.set_sensitive(False)
476 | elif self.mirror == "5 disk raidz3":
477 | if len(self.zfs_disk_list) == 5:
478 | self.button3.set_sensitive(True)
479 | else:
480 | self.button3.set_sensitive(False)
481 | elif self.mirror == "2+ disk stripe":
482 | if len(self.zfs_disk_list) >= 2:
483 | self.button3.set_sensitive(True)
484 | else:
485 | self.button3.set_sensitive(False)
486 | else:
487 | if self.check_if_small_disk(model[path][1]) is False:
488 | self.zfs_disk_list.extend([model[path][0] + "-" + model[path][1]])
489 | if self.mirror == "single disk":
490 | if len(self.zfs_disk_list) != 1:
491 | self.button3.set_sensitive(False)
492 | else:
493 | self.button3.set_sensitive(True)
494 | elif self.mirror == "2 disk mirror":
495 | if len(self.zfs_disk_list) == 2:
496 | self.button3.set_sensitive(True)
497 | else:
498 | self.button3.set_sensitive(False)
499 | elif self.mirror == "3 disk raidz1":
500 | if len(self.zfs_disk_list) == 3:
501 | self.button3.set_sensitive(True)
502 | else:
503 | self.button3.set_sensitive(False)
504 | elif self.mirror == "4 disk raidz2":
505 | if len(self.zfs_disk_list) == 4:
506 | self.button3.set_sensitive(True)
507 | else:
508 | self.button3.set_sensitive(False)
509 | elif self.mirror == "5 disk raidz3":
510 | if len(self.zfs_disk_list) == 5:
511 | self.button3.set_sensitive(True)
512 | else:
513 | self.button3.set_sensitive(False)
514 | elif self.mirror == "2+ disk stripe":
515 | if len(self.zfs_disk_list) >= 2:
516 | self.button3.set_sensitive(True)
517 | else:
518 | self.button3.set_sensitive(False)
519 | else:
520 | self.check_cell.set_sensitive(False)
521 | self.small_disk_warning()
522 |
523 | print(self.zfs_disk_list)
524 | return True
525 |
526 | def small_disk_warning(self):
527 | window = Gtk.Window()
528 | window.set_title("Warning")
529 | window.set_border_width(0)
530 | # window.set_size_request(480, 200)
531 | window.set_icon_from_file(logo)
532 | box1 = Gtk.VBox(False, 0)
533 | window.add(box1)
534 | box1.show()
535 | box2 = Gtk.VBox(False, 10)
536 | box2.set_border_width(10)
537 | box1.pack_start(box2, True, True, 0)
538 | box2.show()
539 | warning_text = "Smallest disk need to be SELECTED first!\n"
540 | warning_text += "All the disk selected will reset."
541 | label = Gtk.Label(warning_text)
542 | # Add button
543 | box2.pack_start(label, True, True, 0)
544 | bbox = Gtk.HButtonBox()
545 | bbox.set_border_width(5)
546 | bbox.set_spacing(10)
547 | button = Gtk.Button(stock=Gtk.STOCK_OK)
548 | button.connect("clicked", self.resset_selection, window)
549 | bbox.add(button)
550 | box2.pack_end(bbox, True, True, 5)
551 | window.show_all()
552 |
553 | def resset_selection(self, widget, window):
554 | self.zfs_disk_list = []
555 | rows = len(self.store)
556 | for row in range(0, rows):
557 | self.store[row][3] = False
558 | row += 1
559 | self.check_cell.set_sensitive(True)
560 | window.hide()
561 |
562 | def passwdstrength(self, widget):
563 | passwd = self.password.get_text()
564 | if len(passwd) <= 4:
565 | self.strenght_label.set_text("Super Weak")
566 | elif len(passwd) <= 8:
567 | if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
568 | self.strenght_label.set_text("Super Weak")
569 | elif lowerandNunber(passwd):
570 | self.strenght_label.set_text("Very Weak")
571 | elif upperandNunber(passwd):
572 | self.strenght_label.set_text("Very Weak")
573 | elif lowerUpperCase(passwd):
574 | self.strenght_label.set_text("Very Weak")
575 | elif lowerUpperNumber(passwd):
576 | self.strenght_label.set_text("Fairly Weak")
577 | elif allCharacter(passwd):
578 | self.strenght_label.set_text("Weak")
579 | elif len(passwd) <= 12:
580 | if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
581 | self.strenght_label.set_text("Very Weak")
582 | elif lowerandNunber(passwd):
583 | self.strenght_label.set_text("Fairly Weak")
584 | elif upperandNunber(passwd):
585 | self.strenght_label.set_text("Fairly Weak")
586 | elif lowerUpperCase(passwd):
587 | self.strenght_label.set_text("Fairly Weak")
588 | elif lowerUpperNumber(passwd):
589 | self.strenght_label.set_text("Weak")
590 | elif allCharacter(passwd):
591 | self.strenght_label.set_text("Strong")
592 | elif len(passwd) <= 16:
593 | if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
594 | self.strenght_label.set_text("Fairly Weak")
595 | elif lowerandNunber(passwd):
596 | self.strenght_label.set_text("Weak")
597 | elif upperandNunber(passwd):
598 | self.strenght_label.set_text("Weak")
599 | elif lowerUpperCase(passwd):
600 | self.strenght_label.set_text("Weak")
601 | elif lowerUpperNumber(passwd):
602 | self.strenght_label.set_text("Strong")
603 | elif allCharacter(passwd):
604 | self.strenght_label.set_text("Fairly Strong")
605 | elif len(passwd) <= 20:
606 | if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
607 | self.strenght_label.set_text("Weak")
608 | elif lowerandNunber(passwd):
609 | self.strenght_label.set_text("Strong")
610 | elif upperandNunber(passwd):
611 | self.strenght_label.set_text("Strong")
612 | elif lowerUpperCase(passwd):
613 | self.strenght_label.set_text("Strong")
614 | elif lowerUpperNumber(passwd):
615 | self.strenght_label.set_text("Fairly Strong")
616 | elif allCharacter(passwd):
617 | self.strenght_label.set_text("Very Strong")
618 | elif len(passwd) <= 24:
619 | if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
620 | self.strenght_label.set_text("Strong")
621 | elif lowerandNunber(passwd):
622 | self.strenght_label.set_text("Fairly Strong")
623 | elif upperandNunber(passwd):
624 | self.strenght_label.set_text("Fairly Strong")
625 | elif lowerUpperCase(passwd):
626 | self.strenght_label.set_text("Fairly Strong")
627 | elif lowerUpperNumber(passwd):
628 | self.strenght_label.set_text("Very Strong")
629 | elif allCharacter(passwd):
630 | self.strenght_label.set_text("Super Strong")
631 | elif len(passwd) > 24:
632 | if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
633 | self.strenght_label.set_text("Fairly Strong")
634 | else:
635 | self.strenght_label.set_text("Super Strong")
636 |
637 | def passwdVerification(self, widget):
638 | if self.password.get_text() == self.repassword.get_text():
639 | self.img.set_from_stock(Gtk.STOCK_YES, 5)
640 | if self.mirror == "single disk":
641 | if len(self.zfs_disk_list) != 1:
642 | self.button3.set_sensitive(False)
643 | else:
644 | self.button3.set_sensitive(True)
645 | elif self.mirror == "2 disk mirror":
646 | if len(self.zfs_disk_list) == 2:
647 | self.button3.set_sensitive(True)
648 | else:
649 | self.button3.set_sensitive(False)
650 | elif self.mirror == "3 disk raidz1":
651 | if len(self.zfs_disk_list) == 3:
652 | self.button3.set_sensitive(True)
653 | else:
654 | self.button3.set_sensitive(False)
655 | elif self.mirror == "4 disk raidz2":
656 | if len(self.zfs_disk_list) == 4:
657 | self.button3.set_sensitive(True)
658 | else:
659 | self.button3.set_sensitive(False)
660 | elif self.mirror == "5 disk raidz3":
661 | if len(self.zfs_disk_list) == 5:
662 | self.button3.set_sensitive(True)
663 | else:
664 | self.button3.set_sensitive(False)
665 | elif self.mirror == "2+ disk stripe":
666 | if len(self.zfs_disk_list) >= 2:
667 | self.button3.set_sensitive(True)
668 | else:
669 | self.button3.set_sensitive(False)
670 | else:
671 | self.img.set_from_stock(Gtk.STOCK_NO, 5)
672 | self.button3.set_sensitive(False)
673 |
--------------------------------------------------------------------------------
/src/welcome_live.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | from gi.repository import Gtk, Gdk, GdkPixbuf
4 | import os
5 | import os.path
6 | from sys_handler import language_dictionary
7 | # Folder use for the installer.
8 | tmp = "/tmp/.gbi/"
9 | installer = "/usr/local/lib/gbi/"
10 | query = "sh /usr/local/lib/gbi/backend-query/"
11 | if not os.path.exists(tmp):
12 | os.makedirs(tmp)
13 | logo = "/usr/local/lib/gbi/logo.png"
14 | langfile = '%slanguage' % tmp
15 | lang_dictionary = language_dictionary()
16 |
17 | Messages = """To run GhostBSD without installing, select "Try GhostBSD."
18 |
19 | To install GhostBSD on your computer hard disk drive, click "Install GhostBSD."
20 |
21 | Note: Language selection only works when selecting "Try GhostBSD."
22 | When installing GhostBSD, the installation program is only in English."""
23 |
24 | cssProvider = Gtk.CssProvider()
25 | cssProvider.load_from_path('/usr/local/lib/gbi/ghostbsd-style.css')
26 | screen = Gdk.Screen.get_default()
27 | styleContext = Gtk.StyleContext()
28 | styleContext.add_provider_for_screen(
29 | screen,
30 | cssProvider,
31 | Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
32 | )
33 |
34 |
35 | class Welcome:
36 |
37 | # On selection it overwrite the delfaut language file.
38 | def Language_Selection(self, tree_selection):
39 | model, treeiter = tree_selection.get_selected()
40 | if treeiter is not None:
41 | value = model[treeiter][0]
42 | self.language = lang_dictionary[value]
43 | return
44 |
45 | def Language_Columns(self, treeView):
46 | cell = Gtk.CellRendererText()
47 | column = Gtk.TreeViewColumn(None, cell, text=0)
48 | column_header = Gtk.Label('Language')
49 | column_header.set_use_markup(True)
50 | column_header.show()
51 | column.set_widget(column_header)
52 | column.set_sort_column_id(0)
53 | treeView.append_column(column)
54 | return
55 |
56 | def save_selection(self):
57 | lang_file = open(langfile, 'w')
58 | lang_file.writelines(self.language)
59 | lang_file.close()
60 | return
61 |
62 | def install_system(self, widget):
63 | self.what = 'install'
64 | self.install_ghostbsd()
65 |
66 | def try_system(self, widget):
67 | self.what = 'try'
68 | self.try_ghostbsd()
69 |
70 | def get_what(self):
71 | return self.what
72 |
73 | def __init__(self, next_install_page, next_setup_install):
74 | self.install_ghostbsd = next_install_page
75 | self.try_ghostbsd = next_setup_install
76 | self.vbox1 = Gtk.VBox(False, 0)
77 | self.vbox1.show()
78 | main_grid = Gtk.Grid()
79 | Title = Gtk.Label('Welcome To GhostBSD!', name="Header")
80 | Title.set_property("height-request", 50)
81 | self.vbox1.pack_start(Title, False, False, 0)
82 | self.vbox1.pack_start(main_grid, True, True, 0)
83 | sw = Gtk.ScrolledWindow()
84 | sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
85 | sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
86 | store = Gtk.TreeStore(str)
87 | for line in lang_dictionary:
88 | store.append(None, [line])
89 | treeView = Gtk.TreeView(store)
90 | treeView.set_model(store)
91 | treeView.set_rules_hint(True)
92 | self.Language_Columns(treeView)
93 | tree_selection = treeView.get_selection()
94 | tree_selection.set_mode(Gtk.SelectionMode.SINGLE)
95 | tree_selection.connect("changed", self.Language_Selection)
96 | sw.add(treeView)
97 | sw.show()
98 | vbox2 = Gtk.VBox(False, 0)
99 | vbox2.set_border_width(10)
100 | vbox2.show()
101 | pixbuf1 = GdkPixbuf.Pixbuf.new_from_file_at_scale(
102 | filename='/usr/local/lib/gbi/laptop.png',
103 | width=190,
104 | height=190,
105 | preserve_aspect_ratio=True
106 | )
107 | image1 = Gtk.Image.new_from_pixbuf(pixbuf1)
108 | image1.show()
109 | pixbuf2 = GdkPixbuf.Pixbuf.new_from_file_at_scale(
110 | filename='/usr/local/lib/gbi/disk.png',
111 | width=120,
112 | height=120,
113 | preserve_aspect_ratio=True)
114 | image2 = Gtk.Image.new_from_pixbuf(pixbuf2)
115 | image2.show()
116 | install_button = Gtk.Button(label='Install GhostBSD', image=image1,
117 | image_position=2)
118 | install_button.set_always_show_image(True)
119 | install_button.connect("clicked", self.install_system)
120 | try_button = Gtk.Button(label='Try GhostBSD', image=image2,
121 | image_position=2)
122 | try_button.set_always_show_image(True)
123 | try_button.connect("clicked", self.try_system)
124 | text_label = Gtk.Label(Messages)
125 | text_label.set_line_wrap(True)
126 | right_grid = Gtk.Grid()
127 | right_grid.set_row_spacing(10)
128 | right_grid.set_column_spacing(2)
129 | right_grid.set_column_homogeneous(True)
130 | right_grid.set_row_homogeneous(True)
131 | right_grid.set_margin_left(10)
132 | right_grid.set_margin_right(10)
133 | right_grid.set_margin_top(10)
134 | right_grid.set_margin_bottom(10)
135 | right_grid.attach(install_button, 1, 1, 1, 5)
136 | right_grid.attach(try_button, 2, 1, 1, 5)
137 | right_grid.attach(text_label, 1, 6, 2, 5)
138 | main_grid.set_row_spacing(10)
139 | main_grid.set_column_spacing(4)
140 | main_grid.set_column_homogeneous(True)
141 | main_grid.set_row_homogeneous(True)
142 | main_grid.set_margin_left(10)
143 | main_grid.set_margin_right(10)
144 | main_grid.set_margin_top(10)
145 | main_grid.set_margin_bottom(10)
146 | main_grid.attach(sw, 1, 1, 1, 10)
147 | main_grid.attach(right_grid, 2, 1, 3, 10)
148 | main_grid.show()
149 | return
150 |
151 | def get_model(self):
152 | return self.vbox1
153 |
--------------------------------------------------------------------------------