commit initial code go gbinstall forked from gbi
@@ -1,25 +1,27 @@
|
||||
BSD 2-Clause License
|
||||
|
||||
Copyright (c) 2018, GhostBSD
|
||||
Copyright (c) 2014, GhostBSD
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* Neither the name of the GhostBSD nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
# gbinstall
|
||||
New GhostBSD installer
|
||||
gbinstall
|
||||
===
|
||||
|
||||
gbinstall is a graphical interface for pc-sysinstall and it is the new installer for GhostBSD.
|
||||
|
||||
To test this code in your environment run "python3.6 setup.py install" as root.
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/usr/local/bin/python
|
||||
|
||||
import sys
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
installer = "/usr/local/lib/gbinstall/"
|
||||
sys.path.append(installer)
|
||||
from gbiWindow import MainWindow
|
||||
|
||||
|
||||
def main():
|
||||
Gtk.main()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
MainWindow()
|
||||
main()
|
||||
@@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import sys
|
||||
# from glob import glob
|
||||
from setuptools import setup
|
||||
|
||||
# import DistUtilsExtra.command.build_extra
|
||||
# import DistUtilsExtra.command.build_i18n
|
||||
# import DistUtilsExtra.command.clean_i18n
|
||||
|
||||
# to update i18n .mo files (and merge .pot file into .po files) run on Linux:
|
||||
# ,,python setup.py build_i18n -m''
|
||||
|
||||
# silence pyflakes, __VERSION__ is properly assigned below...
|
||||
__VERSION__ = '0.1'
|
||||
|
||||
# for line in open('gbinstall', 'r').readlines():
|
||||
# if (line.startswith('__VERSION__')):
|
||||
# exec(line.strip())
|
||||
PROGRAM_VERSION = __VERSION__
|
||||
|
||||
|
||||
def datafilelist(installbase, sourcebase):
|
||||
datafileList = []
|
||||
for root, subFolders, files in os.walk(sourcebase):
|
||||
fileList = []
|
||||
for f in files:
|
||||
fileList.append(os.path.join(root, f))
|
||||
datafileList.append((root.replace(sourcebase, installbase), fileList))
|
||||
return datafileList
|
||||
|
||||
|
||||
prefix = sys.prefix
|
||||
|
||||
lib_gbinstall = [
|
||||
'src/create_cfg.py',
|
||||
'src/db_partition.py',
|
||||
'src/end.py',
|
||||
'src/error.py',
|
||||
'src/gbiWindow.py',
|
||||
'src/ghostbsd-style.css',
|
||||
'src/install.png',
|
||||
'src/install.py',
|
||||
'src/installType.py',
|
||||
'src/language.py',
|
||||
'src/logo.png',
|
||||
'src/partition.py',
|
||||
'src/slides.py',
|
||||
'src/sys_handler.py',
|
||||
'src/use_ufs.py',
|
||||
'src/use_zfs.py'
|
||||
]
|
||||
|
||||
slide_images = [
|
||||
'src/slide-images/ghostbsd/browser.png',
|
||||
'src/slide-images/ghostbsd/customize.png',
|
||||
'src/slide-images/ghostbsd/email.png',
|
||||
'src/slide-images/ghostbsd/help.png',
|
||||
'src/slide-images/ghostbsd/G-logo.png',
|
||||
'src/slide-images/ghostbsd/music.png',
|
||||
'src/slide-images/ghostbsd/office.png',
|
||||
'src/slide-images/ghostbsd/photo.png',
|
||||
'src/slide-images/ghostbsd/social.png',
|
||||
'src/slide-images/ghostbsd/software.png',
|
||||
'src/slide-images/ghostbsd/welcome.png'
|
||||
]
|
||||
|
||||
# '{prefix}/share/man/man1'.format(prefix=sys.prefix), glob('data/*.1')),
|
||||
|
||||
data_files = [
|
||||
(f'{prefix}/share/applications', ['src/gbinstall.desktop']),
|
||||
(f'{prefix}/lib/gbinstall', lib_gbinstall),
|
||||
(f'{prefix}/lib/gbinstall/slide-images/ghostbsd', slide_images)
|
||||
]
|
||||
|
||||
# data_files.extend(datafilelist('{prefix}/share/locale'.format(prefix=sys.prefix), 'build/mo'))
|
||||
|
||||
# cmdclass ={
|
||||
# "build" : DistUtilsExtra.command.build_extra.build_extra,
|
||||
# "build_i18n" : DistUtilsExtra.command.build_i18n.build_i18n,
|
||||
# "clean": DistUtilsExtra.command.clean_i18n.clean_i18n,
|
||||
# }
|
||||
|
||||
setup(name="gbinstall",
|
||||
version=PROGRAM_VERSION,
|
||||
description="Gbinstall is a GTK front end user interface for pc-sysinstall",
|
||||
license='BSD',
|
||||
author='Eric Turgeon',
|
||||
url='https://github/GhostBSD/gbinstall/',
|
||||
package_dir={'': '.'},
|
||||
data_files=data_files,
|
||||
# install_requires = [ 'setuptools', ],
|
||||
scripts=['gbinstall'],)
|
||||
# cmdclass = cmdclass,
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
dmesgLine=`dmesg | grep "acpi_acad0"`
|
||||
if test "${dmesgLine}" = ""; then
|
||||
echo "laptop: NO"
|
||||
else
|
||||
echo "laptop: YES"
|
||||
fi
|
||||
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm /tmp/netCards 2>/dev/null
|
||||
touch /tmp/netCards
|
||||
|
||||
config="`ifconfig -l`"
|
||||
|
||||
for i in $config
|
||||
do
|
||||
echo "${i}" | grep -e "lo0" -e "^fwe" -e "^fwip" -e "lo1" -e "^plip" -e "^pfsync" -e "^pflog" -e "^tun" >/dev/null 2>/dev/null
|
||||
if [ "$?" != "0" ]
|
||||
then
|
||||
IDENT="<`dmesg | grep ^${i} | grep -v "miibus" | grep '<' | cut -d '<' -f 2 | cut -d '>' -f 1 | head -1`>"
|
||||
echo "${i}: $IDENT"
|
||||
fi
|
||||
done
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2009-2012, GhostBSD. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistribution's of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistribution's in binary form must reproduce the above
|
||||
# copyright notice,this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# 3. Neither then name of GhostBSD Project nor the names of its
|
||||
# contributors maybe used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# /usr/local/etc/gbi/detect-sheme.sh v 0.1 Wed May 1 20:31:52 ADT 2013 Eric Turgeon
|
||||
#
|
||||
# Detect a disk sheme and display them.
|
||||
#
|
||||
|
||||
|
||||
DISK="${1}"
|
||||
TMPDIR=${TMPDIR:-"/tmp"}
|
||||
# Display if this is GPT or MBR formatted
|
||||
gpart show ${1} | grep "GPT" >/dev/null 2>/dev/null
|
||||
if [ "$?" = "0" ] ; then
|
||||
#echo "${1}-format: GPT"
|
||||
TYPE="GPT"
|
||||
else
|
||||
#echo "${1}-format: MBR"
|
||||
TYPE="MBR"
|
||||
fi
|
||||
|
||||
echo ${TYPE}
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
pciconf -lv | grep -i vmware >/dev/null 2>/dev/null
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
echo "vmware: YES"
|
||||
exit 0
|
||||
else
|
||||
echo "vmware: NO"
|
||||
exit 1
|
||||
fi
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
NIC="$1"
|
||||
ifconfig ${NIC} | grep -q "802.11" 2>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo 'yes'
|
||||
else
|
||||
echo 'no'
|
||||
fi
|
||||
@@ -0,0 +1,72 @@
|
||||
#!/bin/sh
|
||||
# Query a disk for partitions and display them
|
||||
#############################
|
||||
|
||||
|
||||
if [ -z "${1}" ]
|
||||
then
|
||||
echo "Error: No disk specified!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -e "/dev/${1}" ]
|
||||
then
|
||||
echo "Error: Disk /dev/${1} does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Function to convert bytes to megabytes
|
||||
convert_byte_to_megabyte()
|
||||
{
|
||||
if [ -z "${1}" ]
|
||||
then
|
||||
echo "Error: No bytes specified!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
expr -e ${1} / 1048576
|
||||
};
|
||||
|
||||
# Function which returns a target disks cylinders
|
||||
get_disk_cyl()
|
||||
{
|
||||
cyl=`diskinfo -v ${1} | grep "# Cylinders" | tr -s ' ' | cut -f 2`
|
||||
export VAL="${cyl}"
|
||||
};
|
||||
DISK="${1}"
|
||||
|
||||
# Function which returns a target disks heads
|
||||
get_disk_heads()
|
||||
{
|
||||
head=`diskinfo -v ${1} | grep "# Heads" | tr -s ' ' | cut -f 2`
|
||||
export VAL="${head}"
|
||||
};
|
||||
|
||||
# Function which returns a target disks sectors
|
||||
get_disk_sectors()
|
||||
{
|
||||
sec=`diskinfo -v ${1} | grep "# Sectors" | tr -s ' ' | cut -f 2`
|
||||
export VAL="${sec}"
|
||||
};
|
||||
|
||||
get_disk_cyl "${DISK}"
|
||||
CYLS="${VAL}"
|
||||
|
||||
get_disk_heads "${DISK}"
|
||||
HEADS="${VAL}"
|
||||
|
||||
get_disk_sectors "${DISK}"
|
||||
SECS="${VAL}"
|
||||
|
||||
#echo "cylinders=${CYLS}"
|
||||
#echo "heads=${HEADS}"
|
||||
#echo "sectors=${SECS}"
|
||||
|
||||
# Now get the disks size in MB
|
||||
KB="`diskinfo -v ${1} | grep 'bytes' | cut -d '#' -f 1 | tr -s '\t' ' ' | tr -d ' '`"
|
||||
MB=$(convert_byte_to_megabyte ${KB})
|
||||
#echo "size=$MB"
|
||||
echo "$MB"
|
||||
# Now get the Controller Type
|
||||
CTYPE="`dmesg | grep "^${1}:" | grep "B <" | cut -d '>' -f 2 | cut -d ' ' -f 3-10`"
|
||||
#echo "type=$CTYPE"
|
||||
@@ -0,0 +1,87 @@
|
||||
#!/bin/sh
|
||||
#-
|
||||
# Copyright (c) 2018 iXsystems, Inc. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# $FreeBSD: $
|
||||
|
||||
# Query mbr partitions label and display them
|
||||
##############################
|
||||
|
||||
. ${PROGDIR}/backend/functions.sh
|
||||
. ${PROGDIR}/backend/functions-disk.sh
|
||||
|
||||
|
||||
if [ -z "${1}" ]
|
||||
then
|
||||
echo "Error: No partition specified!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -e "/dev/${1}" ]
|
||||
then
|
||||
echo "Error: Partition /dev/${1} does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
DISK="${1}"
|
||||
TMPDIR=${TMPDIR:-"/tmp"}
|
||||
# Display if this is GPT or MBR formatted
|
||||
gpart show ${1} | grep "GPT" >/dev/null 2>/dev/null
|
||||
if [ "$?" = "0" ] ; then
|
||||
#echo "${1}-format: GPT"
|
||||
TYPE="GPT"
|
||||
else
|
||||
#echo "${1}-format: MBR"
|
||||
TYPE="MBR"
|
||||
fi
|
||||
|
||||
if [ "$TYPE" = "MBR" ] ; then
|
||||
sp="s"
|
||||
else
|
||||
sp="p"
|
||||
fi
|
||||
|
||||
# Get a listing of partitions on this disk
|
||||
gpart show ${DISK} | grep -v ${DISK} | tr -s '\t' ' ' | cut -d ' ' -f 4,3,5 >${TMPDIR}/disk-${DISK}
|
||||
while read i
|
||||
do
|
||||
|
||||
if [ ! -z "${i}" ] ; then
|
||||
BLOCK="`echo ${i} | cut -d ' ' -f 1`"
|
||||
MB="`expr ${BLOCK} / 2048`MB"
|
||||
fi
|
||||
if [ ! "${MB}" = "0MB" ] ; then
|
||||
LABEL="`echo ${i} | cut -d ' ' -f 3`"
|
||||
SLICE="`echo ${i} | cut -d ' ' -f 2`"
|
||||
if [ "$SLICE" = '-' ] ; then
|
||||
echo "freespace ${MB}"
|
||||
else
|
||||
if [ ! -z "$SLICE" ] ; then
|
||||
echo "${MB} ${LABEL}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
done <${TMPDIR}/disk-${DISK}
|
||||
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Create our device listing
|
||||
SYSDISK=$(sysctl -n kern.disks)
|
||||
|
||||
# Now loop through these devices, and list the disk drives
|
||||
for i in ${SYSDISK}
|
||||
do
|
||||
|
||||
# Get the current device
|
||||
DEV="${i}"
|
||||
|
||||
# Make sure we don't find any cd devices
|
||||
case "${DEV}" in
|
||||
acd[0-9]*|cd[0-9]*|scd[0-9]*) continue ;;
|
||||
esac
|
||||
|
||||
# Check the dmesg output for some more info about this device
|
||||
NEWLINE=$(dmesg | sed -n "s/^$DEV: .*<\(.*\)>.*$/ <\1>/p" | head -n 1)
|
||||
if [ -z "$NEWLINE" ]; then
|
||||
NEWLINE=" <Unknown Device>"
|
||||
fi
|
||||
|
||||
# Save the disk list
|
||||
if [ ! -z "$DLIST" ]
|
||||
then
|
||||
DLIST="\n${DLIST}"
|
||||
fi
|
||||
|
||||
DLIST="${DEV} ${NEWLINE}${DLIST}"
|
||||
|
||||
done
|
||||
|
||||
# Echo out the found line
|
||||
echo -e "$DLIST" | sort
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
# Query a disk for partitions and display them
|
||||
#############################
|
||||
|
||||
|
||||
DISK="${1}"
|
||||
TMPDIR=${TMPDIR:-"/tmp"}
|
||||
# Display if this is GPT or MBR formatted
|
||||
gpart show ${1} | grep "GPT" >/dev/null 2>/dev/null
|
||||
if [ "$?" = "0" ] ; then
|
||||
#echo "${1}-format: GPT"
|
||||
TYPE="GPT"
|
||||
else
|
||||
#echo "${1}-format: MBR"
|
||||
TYPE="MBR"
|
||||
fi
|
||||
|
||||
if [ "$TYPE" = "MBR" ] ; then
|
||||
sp="s"
|
||||
else
|
||||
sp="p"
|
||||
fi
|
||||
|
||||
# Get a listing of partitions on this disk
|
||||
gpart show ${DISK} | grep -v ${DISK} | tr -s '\t' ' ' | cut -d ' ' -f 4,3,5 >${TMPDIR}/disk-${DISK}
|
||||
while read i
|
||||
do
|
||||
|
||||
if [ ! -z "${i}" ] ; then
|
||||
BLOCK="`echo ${i} | cut -d ' ' -f 1`"
|
||||
if [ "${BLOCK}" -ge 2048 ] ; then
|
||||
MB="`expr ${BLOCK} / 2048`MB"
|
||||
else
|
||||
MB=1MB
|
||||
fi
|
||||
fi
|
||||
if [ ! "${MB}" = "0MB" ] ; then
|
||||
LABEL="`echo ${i} | cut -d ' ' -f 3`"
|
||||
SLICE="`echo ${i} | cut -d ' ' -f 2`"
|
||||
if [ "$SLICE" = '-' ] ; then
|
||||
if [ ! "${MB}" = "1MB" ] ; then
|
||||
echo "freespace ${MB} none"
|
||||
fi
|
||||
else
|
||||
if [ ! -z "$SLICE" ] ; then
|
||||
echo "${DISK}${sp}${SLICE} ${MB} ${LABEL} "
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done <${TMPDIR}/disk-${DISK}
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
# Script which enables networking with specified options
|
||||
###########################################################################
|
||||
|
||||
. ${PROGDIR}/backend/functions.sh
|
||||
. ${PROGDIR}/conf/pc-sysinstall.conf
|
||||
. ${BACKEND}/functions-networking.sh
|
||||
. ${BACKEND}/functions-parse.sh
|
||||
|
||||
|
||||
NIC="$1"
|
||||
IP="$2"
|
||||
NETMASK="$3"
|
||||
DNS="$4"
|
||||
GATEWAY="$5"
|
||||
MIRRORFETCH="$6"
|
||||
|
||||
if [ -z "${NIC}" ]
|
||||
then
|
||||
echo "ERROR: Usage enable-net <nic> <ip> <netmask> <dns> <gateway>"
|
||||
exit 150
|
||||
fi
|
||||
|
||||
if [ "$NIC" = "AUTO-DHCP" ]
|
||||
then
|
||||
enable_auto_dhcp
|
||||
else
|
||||
echo "Enabling NIC: $NIC"
|
||||
ifconfig ${NIC} ${IP} ${NETMASK}
|
||||
|
||||
echo "nameserver ${DNS}" >/etc/resolv.conf
|
||||
|
||||
route add default ${GATE}
|
||||
fi
|
||||
|
||||
case ${MIRRORFETCH} in
|
||||
ON|on|yes|YES) fetch -o /tmp/mirrors-list.txt ${MIRRORLIST} >/dev/null 2>/dev/null;;
|
||||
*) ;;
|
||||
esac
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
# Script which lists the available components for this release
|
||||
###########################################################################
|
||||
|
||||
. ${PROGDIR}/backend/functions.sh
|
||||
|
||||
echo "Available Components:"
|
||||
|
||||
cd ${COMPDIR}
|
||||
for i in `ls -d *`
|
||||
do
|
||||
if [ -e "${i}/component.cfg" -a -e "${i}/install.sh" -a -e "${i}/distfiles" ]
|
||||
then
|
||||
NAME="`grep 'name:' ${i}/component.cfg | cut -d ':' -f 2`"
|
||||
DESC="`grep 'description:' ${i}/component.cfg | cut -d ':' -f 2`"
|
||||
TYPE="`grep 'type:' ${i}/component.cfg | cut -d ':' -f 2`"
|
||||
echo " "
|
||||
echo "name: ${i}"
|
||||
echo "desc:${DESC}"
|
||||
echo "type:${TYPE}"
|
||||
if [ -e "${i}/component.png" ]
|
||||
then
|
||||
echo "icon: ${COMPDIR}/${i}/component.png"
|
||||
fi
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
# Script which lists the backups present on a server
|
||||
###########################################################################
|
||||
|
||||
. ${PROGDIR}/backend/functions.sh
|
||||
|
||||
SSHUSER=$1
|
||||
SSHHOST=$2
|
||||
SSHPORT=$3
|
||||
|
||||
if [ -z "${SSHHOST}" -o -z "${SSHPORT}" ]
|
||||
then
|
||||
echo "ERROR: Usage list-rsync-backups.sh <user> <host> <port>"
|
||||
exit 150
|
||||
fi
|
||||
|
||||
# Look for full-system backups, needs at minimum a kernel to be bootable
|
||||
FINDCMD="find . -type d -maxdepth 6 -name 'kernel' | grep '/boot/kernel'"
|
||||
|
||||
# Get a listing of the number of full backups saved
|
||||
OLDBACKUPS=`ssh -o 'BatchMode=yes' -p ${SSHPORT} ${SSHUSER}@${SSHHOST} "${FINDCMD}"`
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
for i in ${OLDBACKUPS}
|
||||
do
|
||||
BACKPATH="`echo ${i} | sed 's|/boot/.*||g' | sed 's|^./||g'`"
|
||||
if [ -z "${BACKLIST}" ]
|
||||
then
|
||||
BACKLIST="${BACKPATH}"
|
||||
else
|
||||
BACKLIST="${BACKLIST}:${BACKPATH}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "${BACKLIST}" ]
|
||||
then
|
||||
echo "NONE"
|
||||
else
|
||||
echo "$BACKLIST"
|
||||
fi
|
||||
|
||||
else
|
||||
echo "FAILED"
|
||||
fi
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm ${TMPDIR}/.tzonetmp >/dev/null 2>/dev/null
|
||||
|
||||
# Backend script which lists all the available timezones for front-ends to display
|
||||
while read line
|
||||
do
|
||||
echo "$line" | grep "^#" >/dev/null 2>/dev/null
|
||||
if [ "$?" != "0" ]
|
||||
then
|
||||
echo "$line" | tr -s "\t" ":" | cut -d ":" -f 3-4 >>${TMPDIR}/.tzonetmp
|
||||
fi
|
||||
done < /usr/share/zoneinfo/zone.tab
|
||||
|
||||
sort ${TMPDIR}/.tzonetmp
|
||||
rm -f ${TMPDIR}/.tzonetmp >/dev/null 2>/dev/null
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
FOUND="0"
|
||||
|
||||
cat ${PROGDIR}/conf/avail-langs
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
# Script which creates a gzipped log and optionally mails it to the specified address
|
||||
############################################################################
|
||||
|
||||
. ${PROGDIR}/backend/functions.sh
|
||||
. ${PROGDIR}/conf/pc-sysinstall.conf
|
||||
. ${BACKEND}/functions-networking.sh
|
||||
. ${BACKEND}/functions-parse.sh
|
||||
|
||||
# Bring up all NICS under DHCP
|
||||
enable_auto_dhcp
|
||||
|
||||
MAILTO="$1"
|
||||
MAILRESULT="0"
|
||||
|
||||
# Set the location of our compressed log
|
||||
TMPLOG="/tmp/pc-sysinstall.log"
|
||||
|
||||
echo "# PC-SYSINSTALL LOG" >${TMPLOG}
|
||||
cat ${LOGOUT} >> ${TMPLOG}
|
||||
|
||||
# Check if we have a GUI generated install cfg
|
||||
if [ -e "/tmp/sys-install.cfg" ]
|
||||
then
|
||||
echo "" >>${TMPLOG}
|
||||
echo "# PC-SYSINSTALL CFG " >>${TMPLOG}
|
||||
cat /tmp/sys-install.cfg >> ${TMPLOG}
|
||||
fi
|
||||
|
||||
# Save dmesg output
|
||||
echo "" >>${TMPLOG}
|
||||
echo "# DMESG OUTPUT " >>${TMPLOG}
|
||||
dmesg >> ${TMPLOG}
|
||||
|
||||
# Get gpart info on all disks
|
||||
for i in `${PROGDIR}/pc-sysinstall disk-list | cut -d ':' -f 1`
|
||||
do
|
||||
echo "" >>${TMPLOG}
|
||||
echo "# DISK INFO $i " >>${TMPLOG}
|
||||
ls /dev/${i}* >>${TMPLOG}
|
||||
gpart show ${i} >> ${TMPLOG}
|
||||
done
|
||||
|
||||
# Show Mounted volumes
|
||||
echo "" >>${TMPLOG}
|
||||
echo "# MOUNT OUTPUT " >>${TMPLOG}
|
||||
mount >> ${TMPLOG}
|
||||
|
||||
echo "Log file saved to ${TMPLOG}"
|
||||
echo "Warning: This file will be lost once the system is rebooted."
|
||||
|
||||
echo "Do you wish to view this logfile now? (Y/N)"
|
||||
read tmp
|
||||
if [ "$tmp" = "Y" -o "$tmp" = "y" ]
|
||||
then
|
||||
more ${TMPLOG}
|
||||
fi
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
# Script which sets up password-less logins for ssh host
|
||||
###########################################################################
|
||||
|
||||
. ${PROGDIR}/backend/functions.sh
|
||||
|
||||
SSHUSER=$1
|
||||
SSHHOST=$2
|
||||
SSHPORT=$3
|
||||
|
||||
if [ -z "${SSHUSER}" -o -z "${SSHHOST}" -o -z "${SSHPORT}" ]
|
||||
then
|
||||
echo "ERROR: Usage setup-ssh-keys <user> <host> <port>"
|
||||
exit 150
|
||||
fi
|
||||
|
||||
cd ~
|
||||
|
||||
echo "Preparing to setup SSH key authorization..."
|
||||
echo "When prompted, enter your password for ${SSHUSER}@${SSHHOST}"
|
||||
|
||||
if [ ! -e ".ssh/id_rsa.pub" ]
|
||||
then
|
||||
mkdir .ssh >/dev/null 2>/dev/null
|
||||
ssh-keygen -q -t rsa -N '' -f .ssh/id_rsa
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
if [ ! -e ".ssh/id_rsa.pub" ]
|
||||
then
|
||||
echo "ERROR: Failed creating .ssh/id_rsa.pub"
|
||||
exit 150
|
||||
fi
|
||||
|
||||
# Get the .pub key
|
||||
PUBKEY="`cat .ssh/id_rsa.pub`"
|
||||
|
||||
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"
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
MEM=`sysctl hw.realmem | sed "s|hw.realmem: ||g"`
|
||||
MEM=`expr $MEM / 1024`
|
||||
MEM=`expr $MEM / 1024`
|
||||
echo $MEM
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
# Script which checks if we are running from install media, or real system
|
||||
#############################################################################
|
||||
|
||||
dmesg | grep "md0: Preloaded image" >/dev/null 2>/dev/null
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
echo "INSTALL-MEDIA"
|
||||
exit 0
|
||||
else
|
||||
echo "REAL-DISK"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
# Script which tests "fetch" when using a network connection, and saves
|
||||
# if we are using direct connect, or need FTP passive mode
|
||||
#############################################################################
|
||||
|
||||
rm ${TMPDIR}/.testftp >/dev/null 2>/dev/null
|
||||
|
||||
ping -c 2 www.pcbsd.org >/dev/null 2>/dev/null
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
echo "ftp: Up"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ping -c 2 www.freebsd.org >/dev/null 2>/dev/null
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
echo "ftp: Up"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "ftp: Down"
|
||||
exit 1
|
||||
@@ -0,0 +1,84 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Need access to a some unmount functions
|
||||
. ${PROGDIR}/backend/functions-unmount.sh
|
||||
|
||||
echo "Running: find-update-parts" >> ${LOGOUT}
|
||||
|
||||
rm ${TMPDIR}/AvailUpgrades >/dev/null 2>/dev/null
|
||||
|
||||
FSMNT="/mnt"
|
||||
|
||||
# Get the freebsd version on this partition
|
||||
get_fbsd_ver() {
|
||||
|
||||
VER="`file ${FSMNT}/bin/sh | grep 'for FreeBSD' | sed 's|for FreeBSD |;|g' | cut -d ';' -f 2 | cut -d ',' -f 1`"
|
||||
if [ "$?" = "0" ] ; then
|
||||
file ${FSMNT}/bin/sh | grep '32-bit' >/dev/null 2>/dev/null
|
||||
if [ "${?}" = "0" ] ; then
|
||||
echo "${1}: FreeBSD ${VER} (32bit)"
|
||||
else
|
||||
echo "${1}: FreeBSD ${VER} (64bit)"
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# Create our device listing
|
||||
SYSDISK="`sysctl kern.disks | cut -d ':' -f 2 | sed 's/^[ \t]*//'`"
|
||||
DEVS=""
|
||||
|
||||
# Now loop through these devices, and list the disk drives
|
||||
for i in ${SYSDISK}
|
||||
do
|
||||
|
||||
# Get the current device
|
||||
DEV="${i}"
|
||||
# Make sure we don't find any cd devices
|
||||
echo "${DEV}" | grep -e "^acd[0-9]" -e "^cd[0-9]" -e "^scd[0-9]" >/dev/null 2>/dev/null
|
||||
if [ "$?" != "0" ] ; then
|
||||
DEVS="${DEVS} `ls /dev/${i}*`"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# Search for regular UFS / Geom Partitions to upgrade
|
||||
for i in $DEVS
|
||||
do
|
||||
if [ ! -e "${i}a.journal" -a ! -e "${i}a" -a ! -e "${i}p2" -a ! -e "${i}p2.journal" ] ; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ -e "${i}a.journal" ] ; then
|
||||
_dsk="${i}a.journal"
|
||||
elif [ -e "${i}a" ] ; then
|
||||
_dsk="${i}a"
|
||||
elif [ -e "${i}p2" ] ; then
|
||||
_dsk="${i}p2"
|
||||
elif [ -e "${i}p2.journal" ] ; then
|
||||
_dsk="${i}p2.journal"
|
||||
fi
|
||||
|
||||
mount ${_dsk} ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
|
||||
if [ "${?}" = "0" -a -e "${FSMNT}/bin/sh" ] ; then
|
||||
get_fbsd_ver "`echo ${_dsk} | sed 's|/dev/||g'`"
|
||||
umount -f ${FSMNT} >/dev/null 2>/dev/null
|
||||
fi
|
||||
done
|
||||
|
||||
# Now search for any ZFS root partitions
|
||||
zpool import -o altroot=${FSMNT} -a
|
||||
|
||||
# Unmount any auto-mounted stuff
|
||||
umount_all_dir "${FSMNT}"
|
||||
|
||||
# Get pools
|
||||
_zps="`zpool list | grep -v 'NAME' | cut -d ' ' -f 1`"
|
||||
for _zpools in ${_zps}
|
||||
do
|
||||
mount -t zfs ${_zpools} ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
|
||||
if [ "${?}" = "0" -a -e "${FSMNT}/bin/sh" ] ; then
|
||||
get_fbsd_ver "${_zpools}"
|
||||
umount -f ${FSMNT} >/dev/null 2>/dev/null
|
||||
fi
|
||||
done
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
FOUND="0"
|
||||
|
||||
# Lets parse the xorg.list file, and see what layouts are supported
|
||||
while read line
|
||||
do
|
||||
|
||||
if [ "$FOUND" = "1" -a ! -z "$line" ]
|
||||
then
|
||||
echo $line | grep '! ' >/dev/null 2>/dev/null
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
echo "$line"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${FOUND}" = "0" ]
|
||||
then
|
||||
echo $line | grep '! layout' >/dev/null 2>/dev/null
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
FOUND="1"
|
||||
fi
|
||||
fi
|
||||
|
||||
done < /usr/local/share/X11/xkb/rules/xorg.lst
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
FOUND="0"
|
||||
|
||||
# Lets parse the xorg.list file, and see what models are supported
|
||||
while read line
|
||||
do
|
||||
|
||||
if [ "$FOUND" = "1" -a ! -z "$line" ]
|
||||
then
|
||||
echo $line | grep '! ' >/dev/null 2>/dev/null
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
model="`echo $line | sed 's|(|[|g'`"
|
||||
model="`echo $model | sed 's|)|]|g'`"
|
||||
echo "$model"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${FOUND}" = "0" ]
|
||||
then
|
||||
echo $line | grep '! model' >/dev/null 2>/dev/null
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
FOUND="1"
|
||||
fi
|
||||
fi
|
||||
|
||||
done < /usr/local/share/X11/xkb/rules/xorg.lst
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
FOUND="0"
|
||||
|
||||
# Lets parse the xorg.list file, and see what varients are supported
|
||||
while read line
|
||||
do
|
||||
|
||||
if [ "$FOUND" = "1" -a ! -z "$line" ]
|
||||
then
|
||||
echo $line | grep '! ' >/dev/null 2>/dev/null
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
echo "$line"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${FOUND}" = "0" ]
|
||||
then
|
||||
echo $line | grep '! variant' >/dev/null 2>/dev/null
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
FOUND="1"
|
||||
fi
|
||||
fi
|
||||
|
||||
done < /usr/local/share/X11/xkb/rules/xorg.lst
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,198 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2013 GhostBSD
|
||||
#
|
||||
# See COPYING for licence terms.
|
||||
#
|
||||
# create_cfg.py v 1.4 Friday, January 17 2014 Eric Turgeon
|
||||
#
|
||||
|
||||
import os
|
||||
import pickle
|
||||
|
||||
# Directory use from the installer.
|
||||
tmp = "/tmp/.gbinstall/"
|
||||
installer = "/usr/local/lib/gbinstall/"
|
||||
# Installer data file.
|
||||
disk = f'{tmp}disk'
|
||||
layout = f'{tmp}layout'
|
||||
model = f'{tmp}model'
|
||||
pcinstallcfg = f'{tmp}pcinstall.cfg'
|
||||
user_passwd = f'{tmp}user'
|
||||
language = f'{tmp}language'
|
||||
dslice = f'{tmp}slice'
|
||||
left = f'{tmp}left'
|
||||
partlabel = f'{tmp}partlabel'
|
||||
timezone = f'{tmp}timezone'
|
||||
KBFile = f'{tmp}keyboard'
|
||||
boot_file = f'{tmp}boot'
|
||||
disk_schem = f'{tmp}scheme'
|
||||
zfs_config = f'{tmp}zfs_config'
|
||||
ufs_config = f'{tmp}ufs_config'
|
||||
|
||||
|
||||
class gbsd_cfg():
|
||||
def __init__(self):
|
||||
f = open(pcinstallcfg, 'w')
|
||||
# Installation Mode
|
||||
f.writelines('# Installation Mode\n')
|
||||
f.writelines('installMode=fresh\n')
|
||||
f.writelines('installInteractive=no\n')
|
||||
f.writelines('installType=GhostBSD\n')
|
||||
f.writelines('installMedium=livecd\n')
|
||||
f.writelines('packageType=livecd\n')
|
||||
# System Language
|
||||
if os.path.exists(language):
|
||||
langfile = open(language, 'r')
|
||||
lang = langfile.readlines()[0].rstrip()
|
||||
f.writelines('\n# System Language\n\n')
|
||||
f.writelines(f'localizeLang={lang}\n')
|
||||
os.remove(language)
|
||||
# Keyboard Setting
|
||||
if os.path.exists(KBFile):
|
||||
f.writelines('\n# Keyboard Setting\n')
|
||||
rkb = open(KBFile, 'r')
|
||||
kb = rkb.readlines()
|
||||
kbl = kb[0].rstrip()
|
||||
f.writelines(f'localizeKeyLayout={kbl}\n')
|
||||
kbv = kb[1].rstrip()
|
||||
if kbv != 'None':
|
||||
f.writelines(f'localizeKeyVariant={kbv}\n')
|
||||
kbm = kb[2].rstrip()
|
||||
if kbm != 'None':
|
||||
f.writelines(f'localizeKeyModel={kbm}\n')
|
||||
# Timezone
|
||||
if os.path.exists(timezone):
|
||||
time = open(timezone, 'r')
|
||||
t_output = time.readlines()[0].strip()
|
||||
f.writelines('\n# Timezone\n')
|
||||
f.writelines(f'timeZone={t_output}\n')
|
||||
f.writelines('enableNTP=yes\n')
|
||||
os.remove(timezone)
|
||||
if os.path.exists(zfs_config):
|
||||
# Disk Setup
|
||||
r = open(zfs_config, 'r')
|
||||
zfsconf = r.readlines()
|
||||
for line in zfsconf:
|
||||
if 'partscheme' in line:
|
||||
f.writelines(line)
|
||||
read = open(boot_file, 'r')
|
||||
boot = read.readlines()[0].strip()
|
||||
f.writelines(f'bootManager={boot}\n')
|
||||
os.remove(boot_file)
|
||||
else:
|
||||
f.writelines(line)
|
||||
# os.remove(zfs_config)
|
||||
elif os.path.exists(ufs_config):
|
||||
# Disk Setup
|
||||
r = open(ufs_config, 'r')
|
||||
ufsconf = r.readlines()
|
||||
for line in ufsconf:
|
||||
if 'partscheme' in line:
|
||||
f.writelines(line)
|
||||
read = open(boot_file, 'r')
|
||||
boot = read.readlines()[0].strip()
|
||||
f.writelines(f'bootManager={boot}\n')
|
||||
os.remove(boot_file)
|
||||
else:
|
||||
f.writelines(line)
|
||||
else:
|
||||
# Disk Setup
|
||||
r = open(disk, 'r')
|
||||
drive = r.readlines()
|
||||
d_output = drive[0].strip()
|
||||
f.writelines('\n# Disk Setup\n')
|
||||
f.writelines(f'disk0={d_output}\n')
|
||||
os.remove(disk)
|
||||
# Partition Slice.
|
||||
p = open(dslice, 'r')
|
||||
line = p.readlines()
|
||||
part = line[0].rstrip()
|
||||
f.writelines(f'partition={part}\n')
|
||||
os.remove(dslice)
|
||||
# Boot Menu
|
||||
read = open(boot_file, 'r')
|
||||
line = read.readlines()
|
||||
boot = line[0].strip()
|
||||
f.writelines(f'bootManager={boot}\n')
|
||||
# os.remove(boot_file)
|
||||
# Sheme sheme
|
||||
read = open(disk_schem, 'r')
|
||||
shem = read.readlines()[0]
|
||||
f.writelines(shem + '\n')
|
||||
f.writelines('commitDiskPart\n')
|
||||
# os.remove(disk_schem)
|
||||
# Partition Setup
|
||||
f.writelines('\n# Partition Setup\n')
|
||||
part = open(partlabel, 'r')
|
||||
# If slice and auto file exist add first partition line.
|
||||
# But Swap need to be 0 it will take the rest of the freespace.
|
||||
for line in part:
|
||||
if 'BOOT' in line or 'BIOS' in line or 'UEFI' in line:
|
||||
pass
|
||||
else:
|
||||
f.writelines(f'disk0-part={line.strip()}\n')
|
||||
f.writelines('commitDiskLabel\n')
|
||||
os.remove(partlabel)
|
||||
# Network Configuration
|
||||
f.writelines('\n# Network Configuration\n')
|
||||
if os.path.exists(user_passwd):
|
||||
readu = open(user_passwd, 'rb')
|
||||
uf = pickle.load(readu)
|
||||
net = uf[5]
|
||||
f.writelines(f'hostname={net}\n')
|
||||
# Set the root pass
|
||||
if os.path.exists(f'{tmp}root'):
|
||||
readr = open(f'{tmp}root', 'rb')
|
||||
rf = pickle.load(readr)
|
||||
root = rf[0]
|
||||
f.writelines('\n# Set the root pass\n')
|
||||
f.writelines(f'rootPass={root}\n')
|
||||
if os.path.exists(user_passwd):
|
||||
# Network Configuration
|
||||
f.writelines('\n# Network Configuration\n')
|
||||
readu = open(user_passwd, 'rb')
|
||||
uf = pickle.load(readu)
|
||||
net = uf[5]
|
||||
f.writelines(f'hostname={net}\n')
|
||||
user = uf[0]
|
||||
# Setup our users
|
||||
f.writelines('\n# Setup user\n')
|
||||
f.writelines(f'userName={user}\n')
|
||||
name = uf[1]
|
||||
f.writelines(f'userComment={name}\n')
|
||||
passwd = uf[2]
|
||||
f.writelines(f'userPass={passwd.rstrip()}\n')
|
||||
shell = uf[3]
|
||||
f.writelines(f'userShell={shell}\n')
|
||||
upath = uf[4]
|
||||
f.writelines(f'userHome={upath.rstrip()}\n')
|
||||
f.writelines(f'defaultGroup=wheel\n')
|
||||
f.writelines(f'userGroups=operator\n')
|
||||
f.writelines('commitUser\n')
|
||||
f.writelines('runScript=/root/iso_to_hd.sh\n')
|
||||
f.writelines('runCommand=rm -f /root/iso_to_hd.sh\n')
|
||||
if os.path.exists(zfs_config):
|
||||
zfsark = """echo 'vfs.zfs.arc_max="512M"' >> /boot/loader.conf"""
|
||||
f.writelines(f'runCommand={zfsark}')
|
||||
# adding setting for keyboard in slim
|
||||
keyboard_conf = '/usr/local/etc/X11/xorg.conf.d/keyboard.conf'
|
||||
k_conf_list = [
|
||||
'Section "InputClass"',
|
||||
' Identifier "Keyboard0"',
|
||||
' Driver "kbd"',
|
||||
f' Option "XkbLayout" "{kbl}"'
|
||||
]
|
||||
if kbv != 'None':
|
||||
k_conf_list.append(f' Option "XkbVariant" "{kbv}"')
|
||||
if kbm != 'None':
|
||||
k_conf_list.append(f' Option "XkbModel" "{kbm}"')
|
||||
k_conf_list.append('EndSection')
|
||||
for conf_line in k_conf_list:
|
||||
if 'Section "InputClass"' == conf_line:
|
||||
cmd = f"""echo '{conf_line}' > {keyboard_conf}"""
|
||||
else:
|
||||
cmd = f"""echo '{conf_line}' >> {keyboard_conf}"""
|
||||
f.writelines(f'runCommand={cmd}\n')
|
||||
f.close()
|
||||
os.remove(user_passwd)
|
||||
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright (c) 2011 GhostBSD
|
||||
#
|
||||
# See COPYING for licence terms.
|
||||
|
||||
import gtk
|
||||
from subprocess import Popen
|
||||
|
||||
lyrics = """Installation is complete. You need to restart the
|
||||
computer in order to use the new installation.
|
||||
You can continue to use this live media, although
|
||||
any changes you make or documents you save will
|
||||
not be preserved on reboot."""
|
||||
|
||||
|
||||
class PyApp(gtk.Window):
|
||||
def on_reboot(self, widget):
|
||||
Popen('shutdown -r now', shell=True)
|
||||
gtk.main_quit()
|
||||
|
||||
def on_close(self, widget):
|
||||
gtk.main_quit()
|
||||
|
||||
def __init__(self):
|
||||
window = gtk.Window()
|
||||
window.set_position(gtk.WIN_POS_CENTER)
|
||||
window.set_border_width(8)
|
||||
window.connect("destroy", gtk.main_quit)
|
||||
window.set_title("Installation Completed")
|
||||
window.set_icon_from_file("/usr/local/lib/gbi/logo.png")
|
||||
box1 = gtk.VBox(False, 0)
|
||||
window.add(box1)
|
||||
box1.show()
|
||||
box2 = gtk.VBox(False, 10)
|
||||
box2.set_border_width(10)
|
||||
box1.pack_start(box2, True, True, 0)
|
||||
box2.show()
|
||||
label = gtk.Label(lyrics)
|
||||
box2.pack_start(label)
|
||||
box2 = gtk.HBox(False, 10)
|
||||
box2.set_border_width(5)
|
||||
box1.pack_start(box2, False, True, 0)
|
||||
box2.show()
|
||||
table = gtk.Table(1, 2, True)
|
||||
restart = gtk.Button("Restart")
|
||||
restart.connect("clicked", self.on_reboot)
|
||||
Continue = gtk.Button("Continue")
|
||||
Continue.connect("clicked", self.on_close)
|
||||
table.attach(Continue, 0, 1, 0, 1)
|
||||
table.attach(restart, 1, 2, 0, 1)
|
||||
box2.pack_start(table)
|
||||
window.show_all()
|
||||
|
||||
PyApp()
|
||||
gtk.main()
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/usr/local/bin/python
|
||||
# Copyright (c) 2011 GhostBSD
|
||||
#
|
||||
# See COPYING for licence terms.
|
||||
|
||||
import gtk
|
||||
from subprocess import Popen
|
||||
|
||||
lyrics = """
|
||||
Please report to
|
||||
, and be sure
|
||||
to provide /tmp/.pc-sysinstall/pc-sysinstall.log.
|
||||
"""
|
||||
|
||||
|
||||
class PyApp:
|
||||
def on_reboot(self, widget):
|
||||
Popen('sudo reboot', shell=True)
|
||||
gtk.main_quit()
|
||||
|
||||
def on_close(self, widget):
|
||||
gtk.main_quit()
|
||||
|
||||
def __init__(self):
|
||||
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
window.set_position(gtk.WIN_POS_CENTER)
|
||||
window.set_border_width(8)
|
||||
window.connect("destroy", gtk.main_quit)
|
||||
window.set_title("Installation Error")
|
||||
# window.set_icon_from_file("/usr/local/lib/gbi/logo.png")
|
||||
box1 = gtk.VBox(False, 0)
|
||||
window.add(box1)
|
||||
box1.show()
|
||||
box2 = gtk.VBox(False, 10)
|
||||
box2.set_border_width(10)
|
||||
box1.pack_start(box2, True, True, 0)
|
||||
box2.show()
|
||||
title = gtk.Label()
|
||||
title.set_use_markup(True)
|
||||
title.set_markup('<b><span size="larger">Installation has failed!</span></b>')
|
||||
label = gtk.Label(lyrics)
|
||||
label.set_use_markup(True)
|
||||
|
||||
label.set_markup("Please report the issue to <a href='http://issues.ghostbsd.org/my_view_page.php'>GhostBSD issue system</a>,\nand be sure to provide /tmp/.pc-sysinstall/pc-sysinstall.log.")
|
||||
box2.pack_start(title)
|
||||
box2.pack_start(label)
|
||||
box2 = gtk.HBox(False, 10)
|
||||
box2.set_border_width(5)
|
||||
box1.pack_start(box2, False, True, 0)
|
||||
box2.show()
|
||||
table = gtk.Table(1, 2, True)
|
||||
ok = gtk.Button("Ok")
|
||||
ok.connect("clicked", self.on_close)
|
||||
table.attach(ok, 0, 2, 0, 1)
|
||||
|
||||
box2.pack_start(table)
|
||||
window.show_all()
|
||||
|
||||
PyApp()
|
||||
gtk.main()
|
||||
@@ -0,0 +1,262 @@
|
||||
#!/usr/local/bin/python
|
||||
"""
|
||||
Copyright (c) 2010-2013, GhostBSD. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistribution's of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistribution's in binary form must reproduce the above
|
||||
copyright notice,this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
3. Neither then name of GhostBSD Project nor the names of its
|
||||
contributors maybe used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import shutil
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
installer = "/usr/local/lib/gbinstall/"
|
||||
sys.path.append(installer)
|
||||
from language import Language
|
||||
from installType import Types
|
||||
from use_ufs import use_ufs
|
||||
from partition import Partitions
|
||||
from use_zfs import ZFS
|
||||
from db_partition import partition_repos
|
||||
from install import installProgress, installSlide
|
||||
logo = "/usr/local/lib/gbinstall/logo.png"
|
||||
tmp = "/tmp/.gbinstall/"
|
||||
if not os.path.exists(tmp):
|
||||
os.makedirs(tmp)
|
||||
disk = '%sdisk' % tmp
|
||||
dslice = '%sslice' % tmp
|
||||
disk_schem = '%sscheme' % tmp
|
||||
zfs_config = '%szfs_config' % tmp
|
||||
ufs_config = '%sufs_config' % tmp
|
||||
partitiondb = "%spartitiondb/" % tmp
|
||||
|
||||
|
||||
class MainWindow():
|
||||
"""Main window class."""
|
||||
|
||||
def delete(self, widget, event=None):
|
||||
"""Close the main window."""
|
||||
if os.path.exists('/tmp/.gbi'):
|
||||
shutil.rmtree('/tmp/.gbi')
|
||||
Gtk.main_quit()
|
||||
return False
|
||||
|
||||
def next_page(self, widget, notebook):
|
||||
"""Go to the next window."""
|
||||
page = self.notebook.get_current_page()
|
||||
if page == 0:
|
||||
self.lang.save_selection()
|
||||
typebox = Gtk.VBox(False, 0)
|
||||
typebox.show()
|
||||
self.types = Types()
|
||||
get_types = self.types.get_model()
|
||||
typebox.pack_start(get_types, True, True, 0)
|
||||
label = Gtk.Label("Types")
|
||||
self.notebook.insert_page(typebox, label, 1)
|
||||
self.window.show_all()
|
||||
self.notebook.next_page()
|
||||
elif page == 1:
|
||||
if self.types.get_type() == "ufs":
|
||||
partition_repos()
|
||||
udbox = Gtk.VBox(False, 0)
|
||||
udbox.show()
|
||||
self.partition = use_ufs(self.button3)
|
||||
get_ud = self.partition.get_model()
|
||||
udbox.pack_start(get_ud, True, True, 0)
|
||||
label = Gtk.Label("UFS Disk Configuration")
|
||||
self.notebook.insert_page(udbox, label, 2)
|
||||
self.window.show_all()
|
||||
self.notebook.next_page()
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.types.get_type() == "custom":
|
||||
partition_repos()
|
||||
Pbox = Gtk.VBox(False, 0)
|
||||
Pbox.show()
|
||||
self.partition = Partitions(self.button3)
|
||||
get_part = self.partition.get_model()
|
||||
Pbox.pack_start(get_part, True, True, 0)
|
||||
label = Gtk.Label("UFS Custom Configuration")
|
||||
self.notebook.insert_page(Pbox, label, 2)
|
||||
self.window.show_all()
|
||||
self.notebook.next_page()
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.types.get_type() == "zfs":
|
||||
Zbox = Gtk.VBox(False, 0)
|
||||
Zbox.show()
|
||||
self.partition = ZFS(self.button3)
|
||||
get_ZFS = self.partition.get_model()
|
||||
Zbox.pack_start(get_ZFS, True, True, 0)
|
||||
label = Gtk.Label("ZFS Configuration")
|
||||
self.notebook.insert_page(Zbox, label, 2)
|
||||
self.window.show_all()
|
||||
self.notebook.next_page()
|
||||
self.button3.set_sensitive(False)
|
||||
elif page == 2:
|
||||
self.partition.save_selection()
|
||||
Rbox = Gtk.VBox(False, 0)
|
||||
Rbox.show()
|
||||
self.rootuser = RootUser(self.button3)
|
||||
get_root = self.rootuser.get_model()
|
||||
Rbox.pack_start(get_root, True, True, 0)
|
||||
label = Gtk.Label("Root Password")
|
||||
self.notebook.insert_page(Rbox, label, 3)
|
||||
self.window.show_all()
|
||||
self.notebook.next_page()
|
||||
self.button3.set_sensitive(False)
|
||||
self.rootuser.save_selection()
|
||||
Abox = Gtk.VBox(False, 0)
|
||||
Abox.show()
|
||||
self.adduser = AddUser(self.button3)
|
||||
get_adduser = self.adduser.get_model()
|
||||
Abox.pack_start(get_adduser, True, True, 0)
|
||||
label = Gtk.Label("Adding User")
|
||||
self.notebook.insert_page(Abox, label, 3)
|
||||
self.button3.set_label("Install")
|
||||
self.window.show_all()
|
||||
self.notebook.next_page()
|
||||
self.button3.set_sensitive(False)
|
||||
elif page == 3:
|
||||
self.adduser.save_selection()
|
||||
Ibox = Gtk.VBox(False, 0)
|
||||
Ibox.show()
|
||||
install = installSlide()
|
||||
get_install = install.get_model()
|
||||
Ibox.pack_start(get_install, True, True, 0)
|
||||
label = Gtk.Label("Installation")
|
||||
self.notebook.insert_page(Ibox, label, 7)
|
||||
self.notebook.next_page()
|
||||
instpro = installProgress()
|
||||
progressBar = instpro.getProgressBar()
|
||||
box1 = Gtk.VBox(False, 0)
|
||||
box1.show()
|
||||
label = Gtk.Label("Progress Bar")
|
||||
box1.pack_end(progressBar, False, False, 0)
|
||||
self.nbButton.insert_page(box1, label, 1)
|
||||
self.nbButton.next_page()
|
||||
self.window.show_all()
|
||||
|
||||
def back_page(self, widget):
|
||||
"""Go back to the previous window."""
|
||||
current_page = self.notebook.get_current_page()
|
||||
if current_page == 1:
|
||||
self.button1.set_sensitive(False)
|
||||
elif current_page == 3:
|
||||
self.button3.set_label("Next")
|
||||
self.notebook.prev_page()
|
||||
new_page = self.notebook.get_current_page()
|
||||
if current_page == 2 and new_page == 1:
|
||||
if os.path.exists(partitiondb):
|
||||
shutil.rmtree(partitiondb)
|
||||
if os.path.exists(tmp + 'create'):
|
||||
os.remove(tmp + 'create')
|
||||
if os.path.exists(tmp + 'delete'):
|
||||
os.remove(tmp + 'delete')
|
||||
if os.path.exists(tmp + 'destroy'):
|
||||
os.remove(tmp + 'destroy')
|
||||
if os.path.exists(tmp + 'partlabel'):
|
||||
os.remove(tmp + 'partlabel')
|
||||
if os.path.exists(zfs_config):
|
||||
os.remove(zfs_config)
|
||||
if os.path.exists(ufs_config):
|
||||
os.remove(ufs_config)
|
||||
if os.path.exists(disk):
|
||||
os.remove(disk)
|
||||
if os.path.exists(dslice):
|
||||
os.remove(dslice)
|
||||
if os.path.exists(disk_schem):
|
||||
os.remove(disk_schem)
|
||||
self.button3.set_sensitive(True)
|
||||
|
||||
def __init__(self):
|
||||
"""Were the Main window start."""
|
||||
self.window = Gtk.Window()
|
||||
self.window.connect("delete_event", self.delete)
|
||||
self.window.set_border_width(0)
|
||||
self.window.set_default_size(800, 500)
|
||||
self.window.set_size_request(800, 500)
|
||||
self.window.set_title("GhostBSD Installer")
|
||||
self.window.set_border_width(0)
|
||||
self.window.set_icon_from_file(logo)
|
||||
mainHBox = Gtk.HBox(False, 0)
|
||||
mainHBox.show()
|
||||
mainVbox = Gtk.VBox(False, 0)
|
||||
mainVbox.show()
|
||||
self.window.add(mainHBox)
|
||||
mainHBox.pack_start(mainVbox, True, True, 0)
|
||||
# Create a new self.notebook
|
||||
self.notebook = Gtk.Notebook()
|
||||
mainVbox.pack_start(self.notebook, True, True, 0)
|
||||
self.notebook.show()
|
||||
self.notebook.set_show_tabs(False)
|
||||
self.notebook.set_show_border(False)
|
||||
vbox = Gtk.VBox(False, 0)
|
||||
vbox.show()
|
||||
self.lang = Language()
|
||||
get_lang = self.lang.get_model()
|
||||
# self.lang = Installs()
|
||||
# get_lang = self.lang.get_model()
|
||||
vbox.pack_start(get_lang, True, True, 0)
|
||||
label = Gtk.Label("Language")
|
||||
self.notebook.insert_page(vbox, label, 0)
|
||||
|
||||
# Set what page to start at Language
|
||||
self.notebook.set_current_page(0)
|
||||
|
||||
# Create buttons
|
||||
self.table = Gtk.Table(1, 6, True)
|
||||
|
||||
self.button1 = Gtk.Button(label='Back')
|
||||
self.button1.connect("clicked", self.back_page)
|
||||
self.table.attach(self.button1, 3, 4, 0, 1)
|
||||
self.button1.show()
|
||||
self.button1.set_sensitive(False)
|
||||
|
||||
self.button2 = Gtk.Button(label='Cancel')
|
||||
self.button2.connect("clicked", self.delete)
|
||||
self.table.attach(self.button2, 4, 5, 0, 1)
|
||||
self.button2.show()
|
||||
|
||||
self.button3 = Gtk.Button(label='Next')
|
||||
self.button3.connect("clicked", self.next_page, self.notebook)
|
||||
self.table.attach(self.button3, 5, 6, 0, 1)
|
||||
self.button3.show()
|
||||
|
||||
self.table.set_col_spacings(5)
|
||||
self.table.show()
|
||||
# Create a new notebook
|
||||
self.nbButton = Gtk.Notebook()
|
||||
mainVbox.pack_end(self.nbButton, False, False, 5)
|
||||
self.nbButton.show()
|
||||
self.nbButton.set_show_tabs(False)
|
||||
self.nbButton.set_show_border(False)
|
||||
label = Gtk.Label("Button")
|
||||
self.nbButton.insert_page(self.table, label, 0)
|
||||
self.window.show_all()
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env xdg-open
|
||||
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Icon[C]=/usr/local/lib/gbinstall/install.png
|
||||
Name[C]=GhostBSD Installer
|
||||
Categories=GNOME;GTK;System;
|
||||
NoDisplay=true
|
||||
Exec=sudo gbi
|
||||
Comment[C]=GhostBSD Installer
|
||||
Name=GhostBSD Installer
|
||||
Comment=GhostBSD Installer
|
||||
Icon=/usr/local/lib/gbi/install.png
|
||||
@@ -0,0 +1,65 @@
|
||||
#welcome {
|
||||
background-image: url("/usr/local/lib/gbi/slide-images/ghostbsd/welcome.png");
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
#software {
|
||||
background-image: url("/usr/local/lib/gbi/slide-images/ghostbsd/software.png");
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
#web {
|
||||
background-image: url("/usr/local/lib/gbi/slide-images/ghostbsd/browser.png");
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
#email {
|
||||
background-image: url("/usr/local/lib/gbi/slide-images/ghostbsd/email.png");
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
#communicate {
|
||||
background-image: url("/usr/local/lib/gbi/slide-images/ghostbsd/social.png");
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
#office {
|
||||
background-image: url("/usr/local/lib/gbi/slide-images/ghostbsd/office.png");
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
#mutimedia {
|
||||
background-image: url("/usr/local/lib/gbi/slide-images/ghostbsd/music.png");
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
#photo {
|
||||
background-image: url("/usr/local/lib/gbi/slide-images/ghostbsd/photo.png");
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
#customize {
|
||||
background-image: url("/usr/local/lib/gbi/slide-images/ghostbsd/customize.png");
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
#help {
|
||||
background-image: url("/usr/local/lib/gbi/slide-images/ghostbsd/help.png");
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
#slideText {
|
||||
color: #F9F9F9;
|
||||
font-weight:bold;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#TransBox {
|
||||
background-color: rgba(0, 0, 0, 0.6)
|
||||
}
|
||||
|
||||
#Header {
|
||||
color: #F9F9F9;
|
||||
background-color: #3C3B37;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1,114 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2013 GhostBSD
|
||||
#
|
||||
# See COPYING for licence terms.
|
||||
#
|
||||
# install.py v 0.4 Sunday, February 08 2015 Eric Turgeon
|
||||
#
|
||||
# install.py give the job to pc-sysinstall to install GhostBSD.
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk, GLib
|
||||
import threading
|
||||
# import locale
|
||||
import os
|
||||
from subprocess import Popen, PIPE, STDOUT, call
|
||||
from time import sleep
|
||||
from db_partition import rDeleteParttion, destroyParttion, makingParttion
|
||||
from create_cfg import gbsd_cfg
|
||||
from slides import gbsdSlides
|
||||
# from slides import dbsdSlides
|
||||
import sys
|
||||
installer = "/usr/local/lib/gbinstall/"
|
||||
sys.path.append(installer)
|
||||
tmp = "/tmp/.gbi/"
|
||||
sysinstall = "/usr/local/sbin/pc-sysinstall"
|
||||
logo = "/usr/local/lib/gbinstall/logo.png"
|
||||
|
||||
|
||||
def update_progess(probar, bartext):
|
||||
new_val = probar.get_fraction() + 0.000003
|
||||
probar.set_fraction(new_val)
|
||||
probar.set_text(bartext[0:80])
|
||||
|
||||
|
||||
def read_output(command, probar):
|
||||
call('service hald stop', shell=True)
|
||||
GLib.idle_add(update_progess, probar, "Creating pcinstall.cfg")
|
||||
|
||||
# If rc.conf.ghostbsd exists run gbsd_cfg
|
||||
gbsd_cfg()
|
||||
call('umount /media/GhostBSD', shell=True)
|
||||
sleep(2)
|
||||
if os.path.exists(tmp + 'delete'):
|
||||
GLib.idle_add(update_progess, probar, "Deleting partition")
|
||||
rDeleteParttion()
|
||||
sleep(1)
|
||||
# destroy disk partition and create scheme
|
||||
if os.path.exists(tmp + 'destroy'):
|
||||
GLib.idle_add(update_progess, probar, "Creating disk partition")
|
||||
destroyParttion()
|
||||
sleep(1)
|
||||
# create partition
|
||||
if os.path.exists(tmp + 'create'):
|
||||
GLib.idle_add(update_progess, probar, "Creating new partitions")
|
||||
makingParttion()
|
||||
sleep(1)
|
||||
p = Popen(command, shell=True, stdin=PIPE, stdout=PIPE,
|
||||
stderr=STDOUT, close_fds=True, universal_newlines=True)
|
||||
while True:
|
||||
line = p.stdout.readline()
|
||||
if not line:
|
||||
break
|
||||
bartext = line.rstrip()
|
||||
GLib.idle_add(update_progess, probar, bartext)
|
||||
# Those for next 4 line is for debugin only.
|
||||
# filer = open("/tmp/.gbi/tmp", "a")
|
||||
# filer.writelines(bartext)
|
||||
# filer.close
|
||||
print(bartext)
|
||||
call('service hald start', shell=True)
|
||||
if bartext.rstrip() == "Installation finished!":
|
||||
Popen('python2.7 %send.py' % installer, shell=True, close_fds=True)
|
||||
call("rm -rf /tmp/.gbi/", shell=True, close_fds=True)
|
||||
Gtk.main_quit()
|
||||
else:
|
||||
Popen('python2.7 %serror.py' % installer, shell=True, close_fds=True)
|
||||
Gtk.main_quit()
|
||||
|
||||
|
||||
class installSlide():
|
||||
|
||||
def close_application(self, widget, event=None):
|
||||
Gtk.main_quit()
|
||||
|
||||
def __init__(self):
|
||||
self.mainHbox = Gtk.HBox(False, 0)
|
||||
self.mainHbox.show()
|
||||
|
||||
self.mainVbox = Gtk.VBox(False, 0)
|
||||
self.mainVbox.show()
|
||||
self.mainHbox.pack_start(self.mainVbox, True, True, 0)
|
||||
slide = gbsdSlides()
|
||||
getSlides = slide.get_slide()
|
||||
self.mainVbox.pack_start(getSlides, True, True, 0)
|
||||
|
||||
def get_model(self):
|
||||
return self.mainHbox
|
||||
|
||||
|
||||
class installProgress():
|
||||
|
||||
def __init__(self):
|
||||
self.pbar = Gtk.ProgressBar()
|
||||
self.pbar.set_show_text(True)
|
||||
command = '%s -c %spcinstall.cfg' % (sysinstall, tmp)
|
||||
thr = threading.Thread(target=read_output,
|
||||
args=(command, self.pbar))
|
||||
thr.setDaemon(True)
|
||||
thr.start()
|
||||
self.pbar.show()
|
||||
|
||||
def getProgressBar(self):
|
||||
return self.pbar
|
||||
@@ -0,0 +1,134 @@
|
||||
#!/usr/local/bin//python
|
||||
#
|
||||
# Copyright (c) 2015 GhostBSD
|
||||
#
|
||||
# See COPYING for licence terms.
|
||||
#
|
||||
# type.py v 0.5 Thursday, Mar 28 2013 19:31:53 Eric Turgeon
|
||||
#
|
||||
# type.py create and delete partition slice for GhostBSD system.
|
||||
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
import os
|
||||
import os.path
|
||||
|
||||
# Folder use pr the installer.
|
||||
tmp = "/tmp/.gbinstall/"
|
||||
installer = "/usr/local/lib/gbinstall/"
|
||||
if not os.path.exists(tmp):
|
||||
os.makedirs(tmp)
|
||||
|
||||
logo = "/usr/local/lib/gbinstall/logo.png"
|
||||
disk_file = '%sdisk' % tmp
|
||||
boot_file = '%sboot' % tmp
|
||||
signal = '%ssignal' % tmp
|
||||
|
||||
|
||||
class Types():
|
||||
|
||||
def fstype(self, radiobutton, val):
|
||||
self.ne = val
|
||||
# if self.ne == "ufs":
|
||||
# self.none.set_active(True)
|
||||
# self.grub.set_sensitive(False)
|
||||
# self.bsd.set_sensitive(False)
|
||||
# self.none.set_sensitive(True)
|
||||
# elif self.ne == "custom":
|
||||
# self.grub.set_active(True)
|
||||
# self.grub.set_sensitive(True)
|
||||
# self.bsd.set_sensitive(True)
|
||||
# self.none.set_sensitive(True)
|
||||
# elif self.ne == "zfs":
|
||||
# self.grub.set_active(True)
|
||||
# self.grub.set_sensitive(True)
|
||||
# self.bsd.set_sensitive(False)
|
||||
# self.none.set_sensitive(False)
|
||||
pass_file = open(signal, 'w')
|
||||
pass_file.writelines(self.ne)
|
||||
pass_file.close
|
||||
return
|
||||
|
||||
def get_type(self):
|
||||
return self.ne
|
||||
|
||||
def get_model(self):
|
||||
return self.box1
|
||||
|
||||
def boot_manager(self, radiobutton, val):
|
||||
self.boot = val
|
||||
boot = open(boot_file, 'w')
|
||||
boot.writelines(self.boot)
|
||||
boot.close()
|
||||
|
||||
def __init__(self):
|
||||
self.box1 = Gtk.VBox(False, 0)
|
||||
self.box1.show()
|
||||
box2 = Gtk.VBox(False, 10)
|
||||
# box2.set_border_width(10)
|
||||
self.box1.pack_start(box2, False, False, 0)
|
||||
box2.show()
|
||||
# auto partition or Customize Disk Partition.
|
||||
bbox = Gtk.VBox()
|
||||
label = Gtk.Label('<b><span size="xx-large">Installation Type And Boot Manager</span></b>')
|
||||
label.set_use_markup(True)
|
||||
box2.pack_start(label, False, False, 10)
|
||||
# create a Hbox to center the radio button.
|
||||
hbox = Gtk.HBox()
|
||||
box2.pack_start(hbox, False, False, 10)
|
||||
full_ufs = Gtk.RadioButton.new_with_label_from_widget(None, "UFS Full Disk Configuration")
|
||||
bbox.pack_start(full_ufs, False, True, 10)
|
||||
full_ufs.connect("toggled", self.fstype, "ufs")
|
||||
self.ne = 'zfs'
|
||||
pass_file = open(signal, 'w')
|
||||
pass_file.writelines(self.ne)
|
||||
pass_file.close
|
||||
full_ufs.show()
|
||||
custom_ufs = Gtk.RadioButton.new_with_label_from_widget(full_ufs, "UFS Custom Disk Configuration")
|
||||
bbox.pack_start(custom_ufs, False, True, 10)
|
||||
custom_ufs.connect("toggled", self.fstype, "custom")
|
||||
custom_ufs.show()
|
||||
full_zfs = Gtk.RadioButton.new_with_label_from_widget(custom_ufs, "ZFS Full Disk Configuration(Recommended option for BE)")
|
||||
bbox.pack_start(full_zfs, False, True, 10)
|
||||
full_zfs.connect("toggled", self.fstype, "zfs")
|
||||
full_ufs.show()
|
||||
hbox.pack_start(bbox, False, False, 50)
|
||||
full_zfs.set_active(True)
|
||||
# Boot option.
|
||||
box3 = Gtk.VBox(False, 0)
|
||||
box3.set_border_width(10)
|
||||
self.box1.pack_start(box3, False, False, 0)
|
||||
box3.show()
|
||||
label = Gtk.Label('<b><span size="x-large">Boot Manager Option</span></b>')
|
||||
label.set_use_markup(True)
|
||||
box3.pack_start(label, False, False, 10)
|
||||
hbox = Gtk.HBox()
|
||||
hbox.show()
|
||||
box3.pack_start(hbox, True, True, 0)
|
||||
bbox1 = Gtk.VBox()
|
||||
bbox1.show()
|
||||
self.grub = Gtk.RadioButton.new_with_label_from_widget(None, "Install Grub 2")
|
||||
# bbox1.pack_start(self.grub, False, True, 10)
|
||||
self.grub.connect("toggled", self.boot_manager, "grub")
|
||||
self.grub.show()
|
||||
self.grub.set_sensitive(False)
|
||||
self.bsd = Gtk.RadioButton.new_with_label_from_widget(None, "Install FreeBSD boot manager + loader(MBR only)")
|
||||
bbox1.pack_start(self.bsd, False, True, 10)
|
||||
self.bsd.connect("toggled", self.boot_manager, "bsd")
|
||||
self.bsd.show()
|
||||
# self.bsd.set_sensitive(False)
|
||||
self.none = Gtk.RadioButton.new_with_label_from_widget(self.bsd, "BIOS: loader only UEFI: install Refind")
|
||||
bbox1.pack_start(self.none, False, True, 10)
|
||||
self.none.connect("toggled", self.boot_manager, "none")
|
||||
self.none.show()
|
||||
hbox.pack_start(bbox1, False, False, 50)
|
||||
self.none.set_active(True)
|
||||
self.boot = "none"
|
||||
boot = open(boot_file, 'w')
|
||||
boot.writelines(self.boot)
|
||||
boot.close()
|
||||
self.box3 = Gtk.VBox(False, 0)
|
||||
self.box3.set_border_width(0)
|
||||
self.box1.pack_start(self.box3, True, True, 0)
|
||||
return
|
||||
@@ -0,0 +1,140 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
#####################################################################
|
||||
# Copyright (c) 2009-2012, GhostBSD. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistribution's of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistribution's in binary form must reproduce the above
|
||||
# copyright notice,this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# 3. Neither then name of GhostBSD Project nor the names of its
|
||||
# contributors maybe used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#####################################################################
|
||||
# language.py show the language for the installer.
|
||||
|
||||
|
||||
from gi.repository import Gtk
|
||||
import os
|
||||
import os.path
|
||||
from sys_handler import language_dictionary
|
||||
# Folder use for the installer.
|
||||
tmp = "/tmp/.gbinstall/"
|
||||
installer = "/usr/local/lib/gbinstall/"
|
||||
if not os.path.exists(tmp):
|
||||
os.makedirs(tmp)
|
||||
logo = "/usr/local/lib/gbinstall/logo.png"
|
||||
langfile = '%slanguage' % tmp
|
||||
lang_dictionary = language_dictionary()
|
||||
# Text to be replace be multiple language file.
|
||||
title = "Welcome To GhostBSD!"
|
||||
welltext = """Select the language you want to use with GhostBSD."""
|
||||
|
||||
|
||||
class Language:
|
||||
|
||||
# On selection it overwrite the delfaut language file.
|
||||
def Language_Selection(self, tree_selection):
|
||||
model, treeiter = tree_selection.get_selected()
|
||||
if treeiter is not None:
|
||||
value = model[treeiter][0]
|
||||
self.language = lang_dictionary[value]
|
||||
return
|
||||
|
||||
def Language_Columns(self, treeView):
|
||||
cell = Gtk.CellRendererText()
|
||||
column = Gtk.TreeViewColumn(None, cell, text=0)
|
||||
column_header = Gtk.Label('Language')
|
||||
column_header.set_use_markup(True)
|
||||
column_header.show()
|
||||
column.set_widget(column_header)
|
||||
column.set_sort_column_id(0)
|
||||
treeView.append_column(column)
|
||||
return
|
||||
|
||||
def save_selection(self):
|
||||
lang_file = open(langfile, 'w')
|
||||
lang_file.writelines(self.language)
|
||||
lang_file.close()
|
||||
return
|
||||
|
||||
# Initial definition.
|
||||
def __init__(self):
|
||||
# Add a Default vertical box
|
||||
self.vbox1 = Gtk.VBox(False, 0)
|
||||
self.vbox1.show()
|
||||
# Add a second vertical box
|
||||
grid = Gtk.Grid()
|
||||
self.vbox1.pack_start(grid, True, True, 0)
|
||||
grid.set_row_spacing(10)
|
||||
grid.set_column_spacing(3)
|
||||
grid.set_column_homogeneous(True)
|
||||
grid.set_row_homogeneous(True)
|
||||
grid.set_margin_left(10)
|
||||
grid.set_margin_right(10)
|
||||
grid.set_margin_top(10)
|
||||
grid.set_margin_bottom(10)
|
||||
# Adding a Scrolling Window
|
||||
sw = Gtk.ScrolledWindow()
|
||||
sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
|
||||
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
# Adding a treestore and store language in it.
|
||||
store = Gtk.TreeStore(str)
|
||||
for line in lang_dictionary:
|
||||
store.append(None, [line])
|
||||
treeView = Gtk.TreeView(store)
|
||||
treeView.set_model(store)
|
||||
treeView.set_rules_hint(True)
|
||||
self.Language_Columns(treeView)
|
||||
tree_selection = treeView.get_selection()
|
||||
tree_selection.set_mode(Gtk.SelectionMode.SINGLE)
|
||||
tree_selection.connect("changed", self.Language_Selection)
|
||||
sw.add(treeView)
|
||||
sw.show()
|
||||
grid.attach(sw, 1, 2, 1, 9)
|
||||
# add text in a label.
|
||||
vhbox = Gtk.VBox(False, 0)
|
||||
vhbox.set_border_width(10)
|
||||
vhbox.show()
|
||||
self.wellcome = Gtk.Label('<span size="xx-large"><b>' + title + '</b></span>')
|
||||
self.wellcome.set_use_markup(True)
|
||||
self.wellcometext = Gtk.Label(welltext)
|
||||
self.wellcometext.set_use_markup(True)
|
||||
table = Gtk.Table()
|
||||
# table.attach(self.wellcome, 0, 1, 1, 2)
|
||||
# wall = Gtk.Label()
|
||||
# table.attach(wall, 0, 1, 2, 3)
|
||||
table.attach(self.wellcometext, 0, 1, 3, 4)
|
||||
vhbox.pack_start(table, False, False, 5)
|
||||
image = Gtk.Image()
|
||||
image.set_from_file(logo)
|
||||
image.show()
|
||||
grid.attach(self.wellcome, 1, 1, 3, 1)
|
||||
vhbox.pack_start(image, True, True, 5)
|
||||
grid.attach(vhbox, 2, 2, 2, 9)
|
||||
grid.show()
|
||||
return
|
||||
|
||||
def get_model(self):
|
||||
return self.vbox1
|
||||
|
After Width: | Height: | Size: 9.7 KiB |
@@ -0,0 +1,674 @@
|
||||
#!/usr/local/bin/python
|
||||
"""
|
||||
Copyright (c) 2010-2017, GhostBSD. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistribution's of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistribution's in binary form must reproduce the above
|
||||
copyright notice,this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
#
|
||||
# partition.py v 1.3 Friday, January 17 2014 Eric Turgeon
|
||||
#
|
||||
# auto_partition.py create and delete partition slice for GhostBSD installer
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk, GObject
|
||||
import os
|
||||
import shutil
|
||||
from db_partition import partition_repos, disk_query, Delete_partition
|
||||
from db_partition import partition_query, label_query, bios_or_uefi
|
||||
from db_partition import autoDiskPartition, autoFreeSpace, first_is_free
|
||||
from db_partition import createLabel, scheme_query, how_partition
|
||||
from db_partition import diskSchemeChanger, createSlice, createPartition
|
||||
|
||||
# Folder use pr the installer.
|
||||
tmp = "/tmp/.gbinstall/"
|
||||
installer = "/usr/local/lib/gbinstall/"
|
||||
query = "sh /usr/local/lib/gbinstall/backend-query/"
|
||||
if not os.path.exists(tmp):
|
||||
os.makedirs(tmp)
|
||||
|
||||
add_part = 'gpart add'
|
||||
disk_part = '%sdisk-part.sh' % query
|
||||
disk_label = '%sdisk-label.sh' % query
|
||||
detect_sheme = '%sdetect-sheme.sh' % query
|
||||
|
||||
part = '%sdisk-part.sh' % query
|
||||
memory = 'sysctl hw.physmem'
|
||||
disk_list = '%sdisk-list.sh' % query
|
||||
disk_info = '%sdisk-info.sh' % query
|
||||
disk_label = '%sdisk-label.sh' % query
|
||||
disk_schem = '%sscheme' % tmp
|
||||
disk_file = '%sdisk' % tmp
|
||||
psize = '%spart_size' % tmp
|
||||
logo = "/usr/local/lib/gbi/logo.png"
|
||||
Part_label = '%spartlabel' % tmp
|
||||
part_schem = '%sscheme' % tmp
|
||||
partitiondb = "%spartitiondb/" % tmp
|
||||
boot_file = "%sboot" % tmp
|
||||
ufs_Partiton_list = []
|
||||
|
||||
|
||||
class Partitions():
|
||||
|
||||
def on_fs(self, widget):
|
||||
self.fs = widget.get_active_text()
|
||||
|
||||
def on_label(self, widget):
|
||||
self.label = widget.get_active_text()
|
||||
|
||||
def save_selection(self):
|
||||
pass
|
||||
|
||||
def on_add_label(self, widget, entry, inumb, path, data):
|
||||
if self.fs == '' or self.label == '':
|
||||
pass
|
||||
else:
|
||||
fs = self.fs
|
||||
lb = self.label
|
||||
cnumb = entry.get_value_as_int()
|
||||
lnumb = inumb - cnumb
|
||||
createLabel(path, lnumb, cnumb, lb, fs, data)
|
||||
self.window.hide()
|
||||
self.update()
|
||||
|
||||
def on_add_partition(self, widget, entry, inumb, path, data):
|
||||
if self.fs == '' or self.label == '':
|
||||
pass
|
||||
else:
|
||||
fs = self.fs
|
||||
lb = self.label
|
||||
cnumb = entry.get_value_as_int()
|
||||
lnumb = inumb - cnumb
|
||||
createPartition(path, lnumb, inumb, cnumb, lb, fs, data)
|
||||
self.window.hide()
|
||||
self.update()
|
||||
|
||||
def cancel(self, widget):
|
||||
self.window.hide()
|
||||
|
||||
def labelEditor(self, path, pslice, size, data1, modify):
|
||||
numb = int(size)
|
||||
self.window = Gtk.Window()
|
||||
self.window.set_title("Add Partition")
|
||||
self.window.set_border_width(0)
|
||||
self.window.set_size_request(480, 200)
|
||||
self.window.set_icon_from_file(logo)
|
||||
box1 = Gtk.VBox(False, 0)
|
||||
self.window.add(box1)
|
||||
box1.show()
|
||||
box2 = Gtk.VBox(False, 10)
|
||||
box2.set_border_width(10)
|
||||
box1.pack_start(box2, True, True, 0)
|
||||
box2.show()
|
||||
# create label
|
||||
# label0 = Gtk.Label("Create Partition Label")
|
||||
table = Gtk.Table(1, 2, True)
|
||||
label1 = Gtk.Label("Type:")
|
||||
label2 = Gtk.Label("Size(MB):")
|
||||
label3 = Gtk.Label("Mount point:")
|
||||
self.fstype = Gtk.ComboBoxText()
|
||||
self.fstype.append_text('UFS')
|
||||
self.fstype.append_text('UFS+S')
|
||||
self.fstype.append_text('UFS+J')
|
||||
self.fstype.append_text('UFS+SUJ')
|
||||
self.fstype.append_text('SWAP')
|
||||
if data1 == 1:
|
||||
read = open(boot_file, 'r')
|
||||
line = read.readlines()
|
||||
boot = line[0].strip()
|
||||
if bios_or_uefi() == "UEFI":
|
||||
self.fstype.append_text("UEFI")
|
||||
self.fs = "UEFI"
|
||||
elif boot == "grub":
|
||||
self.fstype.append_text("BIOS")
|
||||
self.fs = "BIOS"
|
||||
else:
|
||||
self.fstype.append_text("BOOT")
|
||||
self.fs = "BOOT"
|
||||
if data1 == 1 and not os.path.exists(Part_label):
|
||||
self.fstype.set_active(5)
|
||||
elif data1 == 1 and len(self.partfile) == 0:
|
||||
self.fstype.set_active(5)
|
||||
elif self.lablebehind == "/":
|
||||
self.fstype.set_active(4)
|
||||
self.fs = "SWAP"
|
||||
else:
|
||||
self.fstype.set_active(3)
|
||||
self.fs = "UFS+SUJ"
|
||||
self.fstype.connect("changed", self.on_fs)
|
||||
adj = Gtk.Adjustment(numb, 0, numb, 1, 100, 0)
|
||||
self.entry = Gtk.SpinButton(adjustment=adj)
|
||||
if modify is True:
|
||||
self.entry.set_editable(False)
|
||||
else:
|
||||
self.entry.set_editable(True)
|
||||
self.mountpoint = Gtk.ComboBoxText()
|
||||
# self.mountpoint.append_text('select labels')
|
||||
self.label = "none"
|
||||
self.mountpoint.append_text('none')
|
||||
# The space for root '/ ' is to recognise / from the file.
|
||||
self.mountpoint.append_text('/')
|
||||
if os.path.exists(Part_label):
|
||||
if data1 == 1 and len(self.partfile) == 1:
|
||||
self.mountpoint.append_text('/boot')
|
||||
elif data1 == 0 and len(self.partfile) == 0:
|
||||
self.mountpoint.append_text('/boot')
|
||||
elif data1 == 0 and not os.path.exists(Part_label):
|
||||
self.mountpoint.append_text('/boot')
|
||||
self.mountpoint.append_text('/etc')
|
||||
self.mountpoint.append_text('/root')
|
||||
self.mountpoint.append_text('/tmp')
|
||||
self.mountpoint.append_text('/usr')
|
||||
self.mountpoint.append_text('/usr/home')
|
||||
self.mountpoint.append_text('/var')
|
||||
self.mountpoint.set_active(0)
|
||||
self.mountpoint.connect("changed", self.on_label)
|
||||
# table.attach(label0, 0, 2, 0, 1)
|
||||
table.attach(label1, 0, 1, 1, 2)
|
||||
table.attach(self.fstype, 1, 2, 1, 2)
|
||||
table.attach(label2, 0, 1, 2, 3)
|
||||
table.attach(self.entry, 1, 2, 2, 3)
|
||||
table.attach(label3, 0, 1, 3, 4)
|
||||
table.attach(self.mountpoint, 1, 2, 3, 4)
|
||||
box2.pack_start(table, False, False, 0)
|
||||
box2 = Gtk.HBox(False, 10)
|
||||
box2.set_border_width(5)
|
||||
box1.pack_start(box2, False, True, 0)
|
||||
box2.show()
|
||||
# Add button
|
||||
bbox = Gtk.HButtonBox()
|
||||
bbox.set_border_width(5)
|
||||
bbox.set_spacing(10)
|
||||
button = Gtk.Button(stock=Gtk.STOCK_CANCEL)
|
||||
button.connect("clicked", self.cancel)
|
||||
bbox.add(button)
|
||||
button = Gtk.Button(stock=Gtk.STOCK_ADD)
|
||||
if modify is False:
|
||||
if data1 == 0:
|
||||
button.connect("clicked", self.on_add_label, self.entry,
|
||||
numb, path, True)
|
||||
elif data1 == 1:
|
||||
button.connect("clicked", self.on_add_partition, self.entry,
|
||||
numb, path, True)
|
||||
else:
|
||||
if data1 == 0:
|
||||
button.connect("clicked", self.on_add_label, self.entry, numb,
|
||||
path, False)
|
||||
elif data1 == 1:
|
||||
button.connect("clicked", self.on_add_partition, self.entry,
|
||||
numb, path, False)
|
||||
bbox.add(button)
|
||||
box2.pack_end(bbox, True, True, 5)
|
||||
self.window.show_all()
|
||||
|
||||
def sheme_selection(self, combobox):
|
||||
model = combobox.get_model()
|
||||
index = combobox.get_active()
|
||||
data = model[index][0]
|
||||
value = data.partition(':')[0]
|
||||
self.scheme = value
|
||||
|
||||
def add_gpt_mbr(self, widget, data):
|
||||
diskSchemeChanger(self.scheme, self.path, self.slice, self.size)
|
||||
self.update()
|
||||
self.window.hide()
|
||||
if data is False:
|
||||
if scheme_query(self.path) == "MBR" and self.path[1] < 4:
|
||||
self.sliceEditor()
|
||||
elif scheme_query(self.path) == "GPT":
|
||||
self.labelEditor(self.path, self.slice, self.size, 1, False)
|
||||
|
||||
def autoSchemePartition(self, widget):
|
||||
diskSchemeChanger(self.scheme, self.path, self.slice, self.size)
|
||||
self.update()
|
||||
autoDiskPartition(self.slice, self.size, self.scheme)
|
||||
self.update()
|
||||
self.window.hide()
|
||||
|
||||
def schemeEditor(self, data):
|
||||
self.window = Gtk.Window()
|
||||
self.window.set_title("Partition Scheme")
|
||||
self.window.set_border_width(0)
|
||||
self.window.set_size_request(400, 150)
|
||||
self.window.set_icon_from_file("/usr/local/lib/gbi/logo.png")
|
||||
box1 = Gtk.VBox(False, 0)
|
||||
self.window.add(box1)
|
||||
box1.show()
|
||||
box2 = Gtk.VBox(False, 10)
|
||||
box2.set_border_width(10)
|
||||
box1.pack_start(box2, True, True, 0)
|
||||
box2.show()
|
||||
# Creating MBR or GPT drive
|
||||
label = Gtk.Label('<b>Select a partition scheme for this drive:</b>')
|
||||
label.set_use_markup(True)
|
||||
# Adding a combo box to selecting MBR or GPT sheme.
|
||||
self.scheme = 'GPT'
|
||||
shemebox = Gtk.ComboBoxText()
|
||||
shemebox.append_text("GPT: GUID Partition Table")
|
||||
shemebox.append_text("MBR: DOS Partition")
|
||||
shemebox.connect('changed', self.sheme_selection)
|
||||
shemebox.set_active(0)
|
||||
table = Gtk.Table(1, 2, True)
|
||||
table.attach(label, 0, 2, 0, 1)
|
||||
table.attach(shemebox, 0, 2, 1, 2)
|
||||
box2.pack_start(table, False, False, 0)
|
||||
box2 = Gtk.HBox(False, 10)
|
||||
box2.set_border_width(5)
|
||||
box1.pack_start(box2, False, True, 0)
|
||||
box2.show()
|
||||
# Add create_scheme button
|
||||
bbox = Gtk.HButtonBox()
|
||||
bbox.set_border_width(5)
|
||||
bbox.set_spacing(10)
|
||||
button = Gtk.Button(stock=Gtk.STOCK_ADD)
|
||||
if data is None:
|
||||
button.connect("clicked", self.autoSchemePartition)
|
||||
else:
|
||||
button.connect("clicked", self.add_gpt_mbr, data)
|
||||
bbox.add(button)
|
||||
box2.pack_end(bbox, True, True, 5)
|
||||
self.window.show_all()
|
||||
|
||||
def get_value(self, widget, entry):
|
||||
psize = int(entry.get_value_as_int())
|
||||
rs = int(self.size) - psize
|
||||
createSlice(psize, rs, self.path)
|
||||
self.update()
|
||||
self.window.hide()
|
||||
|
||||
def sliceEditor(self):
|
||||
numb = int(self.size)
|
||||
self.window = Gtk.Window()
|
||||
self.window.set_title("Add Partition")
|
||||
self.window.set_border_width(0)
|
||||
self.window.set_size_request(400, 150)
|
||||
self.window.set_icon_from_file("/usr/local/lib/gbi/logo.png")
|
||||
box1 = Gtk.VBox(False, 0)
|
||||
self.window.add(box1)
|
||||
box1.show()
|
||||
box2 = Gtk.VBox(False, 10)
|
||||
box2.set_border_width(10)
|
||||
box1.pack_start(box2, True, True, 0)
|
||||
box2.show()
|
||||
# create Partition slice
|
||||
# label = Gtk.Label('<b>Create a New Partition Slice</b>')
|
||||
# label.set_use_markup(True)
|
||||
# label.set_alignment(0, .5)
|
||||
table = Gtk.Table(1, 2, True)
|
||||
label1 = Gtk.Label("Size(MB):")
|
||||
adj = Gtk.Adjustment(numb, 0, numb, 1, 100, 0)
|
||||
self.entry = Gtk.SpinButton(adjustment=adj)
|
||||
self.entry.set_numeric(True)
|
||||
# table.attach(label, 0, 2, 0, 1)
|
||||
table.attach(label1, 0, 1, 1, 2)
|
||||
table.attach(self.entry, 1, 2, 1, 2)
|
||||
box2.pack_start(table, False, False, 0)
|
||||
box2 = Gtk.HBox(False, 10)
|
||||
box2.set_border_width(5)
|
||||
box1.pack_start(box2, False, True, 0)
|
||||
box2.show()
|
||||
# Add button
|
||||
bbox = Gtk.HButtonBox()
|
||||
bbox.set_border_width(5)
|
||||
bbox.set_spacing(10)
|
||||
button = Gtk.Button(stock=Gtk.STOCK_CANCEL)
|
||||
button.connect("clicked", self.cancel)
|
||||
bbox.add(button)
|
||||
button = Gtk.Button(stock=Gtk.STOCK_ADD)
|
||||
button.connect("clicked", self.get_value, self.entry)
|
||||
bbox.add(button)
|
||||
box2.pack_end(bbox, True, True, 5)
|
||||
self.window.show_all()
|
||||
|
||||
def update(self):
|
||||
oldpath = self.path
|
||||
self.Tree_Store()
|
||||
self.treeview.expand_all()
|
||||
self.treeview.row_activated(oldpath, self.treeview.get_columns()[0])
|
||||
self.treeview.set_cursor(oldpath)
|
||||
|
||||
def delete_partition(self, widget):
|
||||
part = self.slice
|
||||
Delete_partition(part, self.path)
|
||||
self.update()
|
||||
|
||||
def delete_create_button(self):
|
||||
bbox = Gtk.HButtonBox()
|
||||
bbox.set_border_width(5)
|
||||
bbox.set_spacing(10)
|
||||
self.create_bt = Gtk.Button("Create")
|
||||
self.create_bt.connect("clicked", self.create_partition)
|
||||
bbox.add(self.create_bt)
|
||||
self.delete_bt = Gtk.Button("Delete")
|
||||
self.delete_bt.connect("clicked", self.delete_partition)
|
||||
bbox.add(self.delete_bt)
|
||||
self.modifi_bt = Gtk.Button("Modify")
|
||||
self.modifi_bt.connect("clicked", self.modify_partition)
|
||||
# bbox.add(self.modifi_bt)
|
||||
self.revert_bt = Gtk.Button("Revert")
|
||||
self.revert_bt.connect("clicked", self.revertChange)
|
||||
bbox.add(self.revert_bt)
|
||||
self.auto_bt = Gtk.Button("Auto")
|
||||
self.auto_bt.connect("clicked", self.autoPartition)
|
||||
bbox.add(self.auto_bt)
|
||||
return bbox
|
||||
|
||||
def modify_partition(self, widget):
|
||||
if len(self.path) == 3:
|
||||
if self.slice != 'freespace':
|
||||
self.labelEditor(self.path, self.slice, self.size, 0, True)
|
||||
elif len(self.path) == 2 and self.slice != 'freespace':
|
||||
if scheme_query(self.path) == "GPT":
|
||||
self.labelEditor(self.path, self.slice, self.size, 1, True)
|
||||
|
||||
def autoPartition(self, widget):
|
||||
if len(self.path) == 3:
|
||||
pass
|
||||
# elif len(self.path) == 1 and self.scheme is None:
|
||||
# self.schemeEditor(None)
|
||||
# self.update()
|
||||
# elif len(self.path) == 1:
|
||||
# autoDiskPartition(self.slice, self.size, self.scheme)
|
||||
# self.Tree_Store()
|
||||
# self.treeview.expand_all()
|
||||
# self.treeview.set_cursor(self.path)
|
||||
elif self.slice == 'freespace':
|
||||
autoFreeSpace(self.path, self.size)
|
||||
self.Tree_Store()
|
||||
self.treeview.expand_all()
|
||||
self.treeview.set_cursor(self.path)
|
||||
elif len(self.path) == 2:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
self.update()
|
||||
|
||||
def revertChange(self, widget):
|
||||
if os.path.exists(partitiondb):
|
||||
shutil.rmtree(partitiondb)
|
||||
if os.path.exists(tmp + 'create'):
|
||||
os.remove(tmp + 'create')
|
||||
if os.path.exists(tmp + 'delete'):
|
||||
os.remove(tmp + 'delete')
|
||||
if os.path.exists(tmp + 'destroy'):
|
||||
os.remove(tmp + 'destroy')
|
||||
if os.path.exists(Part_label):
|
||||
os.remove(Part_label)
|
||||
partition_repos()
|
||||
self.Tree_Store()
|
||||
self.treeview.expand_all()
|
||||
|
||||
def create_partition(self, widget):
|
||||
print(len(self.path))
|
||||
print(self.path)
|
||||
print(how_partition(self.path))
|
||||
if len(self.path) == 2 and how_partition(self.path) == 1 and self.slice == 'freespace':
|
||||
self.schemeEditor(False)
|
||||
elif len(self.path) == 3:
|
||||
if self.slice == 'freespace':
|
||||
self.labelEditor(self.path, self.slice, self.size, 0, False)
|
||||
elif len(self.path) == 2 and self.slice == 'freespace':
|
||||
if scheme_query(self.path) == "MBR" and self.path[1] < 4:
|
||||
self.sliceEditor()
|
||||
elif scheme_query(self.path) == "GPT":
|
||||
self.labelEditor(self.path, self.slice, self.size, 1, False)
|
||||
else:
|
||||
print('scheme')
|
||||
if how_partition(self.path) == 1:
|
||||
self.schemeEditor(True)
|
||||
elif how_partition(self.path) == 0:
|
||||
self.schemeEditor(True)
|
||||
else:
|
||||
pass
|
||||
|
||||
def partition_selection(self, widget):
|
||||
model, self.iter, = widget.get_selected()
|
||||
if self.iter is not None:
|
||||
self.path = model.get_path(self.iter)
|
||||
tree_iter3 = model.get_iter(self.path[0])
|
||||
self.scheme = model.get_value(tree_iter3, 3)
|
||||
tree_iter = model.get_iter(self.path)
|
||||
self.slice = model.get_value(tree_iter, 0)
|
||||
self.size = model.get_value(tree_iter, 1)
|
||||
if len(self.path) == 2 and self.path[1] > 0 and self.scheme == "MBR":
|
||||
pathbehind = str(self.path[0]) + ":" + str(int(self.path[1] - 1))
|
||||
tree_iter2 = model.get_iter(pathbehind)
|
||||
self.slicebehind = model.get_value(tree_iter2, 0)
|
||||
sl = int(self.path[1]) + 1
|
||||
if 'freespace' in self.slicebehind:
|
||||
slbehind = self.path[1]
|
||||
else:
|
||||
slbehind = int(self.slicebehind.partition('s')[2])
|
||||
elif len(self.path) == 2 and self.path[1] > 0 and self.scheme == "GPT":
|
||||
pathbehind = str(self.path[0]) + ":" + str(int(self.path[1] - 1))
|
||||
tree_iter2 = model.get_iter(pathbehind)
|
||||
self.slicebehind = model.get_value(tree_iter2, 0)
|
||||
self.lablebehind = model.get_value(tree_iter2, 2)
|
||||
sl = int(self.path[1]) + 1
|
||||
if 'freespace' in self.slicebehind:
|
||||
slbehind = self.path[1]
|
||||
else:
|
||||
slbehind = int(self.slicebehind.partition('p')[2])
|
||||
elif len(self.path) == 3 and self.path[2] > 0 and self.scheme == "MBR":
|
||||
if self.path[1] > 0:
|
||||
pathbehind1 = str(self.path[0]) + ":" + str(int(self.path[1] - 1))
|
||||
tree_iter2 = model.get_iter(pathbehind1)
|
||||
self.slicebehind = model.get_value(tree_iter2, 0)
|
||||
else:
|
||||
self.slicebehind = None
|
||||
pathbehind2 = str(self.path[0]) + ":" + str(self.path[1]) + ":" + str(int(self.path[2] - 1))
|
||||
tree_iter3 = model.get_iter(pathbehind2)
|
||||
self.lablebehind = model.get_value(tree_iter3, 2)
|
||||
sl = int(self.path[1]) + 1
|
||||
if self.slicebehind is None:
|
||||
slbehind = self.path[1]
|
||||
elif 'freespace' in self.slicebehind:
|
||||
slbehind = self.path[1]
|
||||
else:
|
||||
slbehind = int(self.slicebehind.partition('s')[2])
|
||||
else:
|
||||
self.slicebehind = None
|
||||
self.lablebehind = None
|
||||
sl = 1
|
||||
slbehind = 0
|
||||
if 'freespace' in self.slice:
|
||||
if self.path[1] > 3 and self.scheme == "MBR":
|
||||
self.create_bt.set_sensitive(False)
|
||||
elif self.slicebehind is None:
|
||||
self.create_bt.set_sensitive(True)
|
||||
elif sl == slbehind:
|
||||
self.create_bt.set_sensitive(False)
|
||||
elif slbehind > 4:
|
||||
self.create_bt.set_sensitive(False)
|
||||
else:
|
||||
self.create_bt.set_sensitive(True)
|
||||
self.delete_bt.set_sensitive(False)
|
||||
self.modifi_bt.set_sensitive(False)
|
||||
self.auto_bt.set_sensitive(True)
|
||||
elif 's' in self.slice:
|
||||
self.create_bt.set_sensitive(False)
|
||||
self.delete_bt.set_sensitive(True)
|
||||
# self.modifi_bt.set_sensitive(True)
|
||||
self.auto_bt.set_sensitive(False)
|
||||
elif 'p' in self.slice:
|
||||
self.create_bt.set_sensitive(False)
|
||||
self.delete_bt.set_sensitive(True)
|
||||
# self.modifi_bt.set_sensitive(True)
|
||||
self.auto_bt.set_sensitive(False)
|
||||
else:
|
||||
self.delete_bt.set_sensitive(False)
|
||||
self.modifi_bt.set_sensitive(False)
|
||||
self.auto_bt.set_sensitive(False)
|
||||
if how_partition(self.path) == 1 and first_is_free(self.path) == 'freespace':
|
||||
self.create_bt.set_sensitive(False)
|
||||
elif how_partition(self.path) == 0:
|
||||
self.create_bt.set_sensitive(True)
|
||||
else:
|
||||
self.create_bt.set_sensitive(False)
|
||||
if os.path.exists(Part_label):
|
||||
rd = open(Part_label, 'r')
|
||||
self.partfile = rd.readlines()
|
||||
# If Find GPT scheme.
|
||||
if os.path.exists(disk_schem):
|
||||
rschm = open(disk_schem, 'r')
|
||||
schm = rschm.readlines()[0]
|
||||
if 'GPT' in schm:
|
||||
if len(self.partfile) >= 2:
|
||||
if 'BOOT' in self.partfile[0] or 'BIOS' in self.partfile[0] or 'UEFI' in self.partfile[0]:
|
||||
if "/boot\n" in self.partfile[1]:
|
||||
if len(self.partfile) >= 3:
|
||||
if '/\n' in self.partfile[1]:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif '/\n' in self.partfile[1]:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
if len(self.partfile) >= 1:
|
||||
if "/boot\n" in self.partfile[0]:
|
||||
if len(self.partfile) >= 2:
|
||||
if '/\n' in self.partfile[1]:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif '/\n' in self.partfile[0]:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
|
||||
def __init__(self, button3):
|
||||
self.button3 = button3
|
||||
self.box1 = Gtk.VBox(False, 0)
|
||||
self.box1.show()
|
||||
box2 = Gtk.VBox(False, 10)
|
||||
box2.set_border_width(0)
|
||||
self.box1.pack_start(box2, True, True, 0)
|
||||
box2.show()
|
||||
# Title
|
||||
Title = Gtk.Label("<b><span size='xx-large'>Partition Editor</span></b> ")
|
||||
Title.set_use_markup(True)
|
||||
box2.pack_start(Title, False, False, 20)
|
||||
# Choosing disk to Select Create or delete partition.
|
||||
label = Gtk.Label("<b>Select a drive:</b>")
|
||||
label.set_use_markup(True)
|
||||
sw = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
|
||||
sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
|
||||
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
self.store = Gtk.TreeStore(str, str, str, str, 'gboolean')
|
||||
self.Tree_Store()
|
||||
self.treeview = Gtk.TreeView(self.store)
|
||||
self.treeview.set_model(self.store)
|
||||
self.treeview.set_rules_hint(True)
|
||||
cell = Gtk.CellRendererText()
|
||||
column = Gtk.TreeViewColumn(None, cell, text=0)
|
||||
column_header = Gtk.Label('Partition')
|
||||
column_header.set_use_markup(True)
|
||||
column_header.show()
|
||||
column.set_widget(column_header)
|
||||
column.set_sort_column_id(0)
|
||||
cell2 = Gtk.CellRendererText()
|
||||
column2 = Gtk.TreeViewColumn(None, cell2, text=0)
|
||||
column_header2 = Gtk.Label('Size(MB)')
|
||||
column_header2.set_use_markup(True)
|
||||
column_header2.show()
|
||||
column2.set_widget(column_header2)
|
||||
cell3 = Gtk.CellRendererText()
|
||||
column3 = Gtk.TreeViewColumn(None, cell3, text=0)
|
||||
column_header3 = Gtk.Label('Mount Point')
|
||||
column_header3.set_use_markup(True)
|
||||
column_header3.show()
|
||||
column3.set_widget(column_header3)
|
||||
cell4 = Gtk.CellRendererText()
|
||||
column4 = Gtk.TreeViewColumn(None, cell4, text=0)
|
||||
column_header4 = Gtk.Label('System/Type')
|
||||
column_header4.set_use_markup(True)
|
||||
column_header4.show()
|
||||
column4.set_widget(column_header4)
|
||||
column.set_attributes(cell, text=0)
|
||||
column2.set_attributes(cell2, text=1)
|
||||
column3.set_attributes(cell3, text=2)
|
||||
column4.set_attributes(cell4, text=3)
|
||||
self.treeview.append_column(column)
|
||||
self.treeview.append_column(column2)
|
||||
self.treeview.append_column(column3)
|
||||
self.treeview.append_column(column4)
|
||||
self.treeview.set_reorderable(True)
|
||||
self.treeview.expand_all()
|
||||
self.tree_selection = self.treeview.get_selection()
|
||||
self.tree_selection.set_mode(Gtk.SelectionMode.SINGLE)
|
||||
self.tree_selection.connect("changed", self.partition_selection)
|
||||
sw.add(self.treeview)
|
||||
sw.show()
|
||||
box2.pack_start(sw, True, True, 0)
|
||||
box2 = Gtk.HBox(False, 10)
|
||||
box2.set_border_width(10)
|
||||
self.box1.pack_start(box2, False, False, 10)
|
||||
box2.show()
|
||||
self.scheme = 'GPT'
|
||||
box2.pack_start(self.delete_create_button(),
|
||||
False, False, 10)
|
||||
return
|
||||
|
||||
def Tree_Store(self):
|
||||
self.store.clear()
|
||||
for disk in disk_query():
|
||||
shem = disk[-1]
|
||||
piter = self.store.append(None, [disk[0], str(disk[1]),
|
||||
disk[2], disk[3], True])
|
||||
if shem == "GPT":
|
||||
for pi in partition_query(disk[0]):
|
||||
self.store.append(piter, [pi[0], str(pi[1]), pi[2],
|
||||
pi[3], True])
|
||||
elif shem == "MBR":
|
||||
for pi in partition_query(disk[0]):
|
||||
piter1 = self.store.append(piter, [pi[0], str(pi[1]),
|
||||
pi[2], pi[3], True])
|
||||
if pi[0] == 'freespace':
|
||||
pass
|
||||
else:
|
||||
for li in label_query(pi[0]):
|
||||
self.store.append(piter1, [li[0], str(li[1]),
|
||||
li[2], li[3], True])
|
||||
return self.store
|
||||
|
||||
def get_model(self):
|
||||
self.tree_selection.select_path(0)
|
||||
return self.box1
|
||||
|
After Width: | Height: | Size: 9.8 KiB |
|
After Width: | Height: | Size: 1.9 MiB |
|
After Width: | Height: | Size: 2.0 MiB |
|
After Width: | Height: | Size: 2.0 MiB |
|
After Width: | Height: | Size: 1.8 MiB |
|
After Width: | Height: | Size: 1.9 MiB |
|
After Width: | Height: | Size: 1.9 MiB |
|
After Width: | Height: | Size: 1.9 MiB |
|
After Width: | Height: | Size: 2.1 MiB |
|
After Width: | Height: | Size: 1.8 MiB |
|
After Width: | Height: | Size: 2.1 MiB |
@@ -0,0 +1,267 @@
|
||||
#!/usr/bin/env python
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
import threading
|
||||
from time import sleep
|
||||
import sys
|
||||
|
||||
installer = "/usr/local/lib/gbinstall/"
|
||||
rcconfgbsd = "/etc/rc.conf.ghostbsd"
|
||||
rcconfdbsd = "/etc/rc.conf.desktopbsd"
|
||||
|
||||
sys.path.append(installer)
|
||||
cssProvider = Gtk.CssProvider()
|
||||
# if os.path.exists(rcconfgbsd):
|
||||
# print(True)
|
||||
cssProvider.load_from_path('/usr/local/lib/gbinstall/ghostbsd-style.css')
|
||||
# elif os.path.exists(rcconfdbsd):
|
||||
# cssProvider.load_from_path('/usr/local/lib/gbi/desktopbsd-style.css')
|
||||
screen = Gdk.Screen.get_default()
|
||||
styleContext = Gtk.StyleContext()
|
||||
styleContext.add_provider_for_screen(screen, cssProvider,
|
||||
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
|
||||
|
||||
|
||||
class gbsdSlides:
|
||||
def Welcome(self):
|
||||
vBox = Gtk.VBox(False, 0)
|
||||
vBox.show()
|
||||
label = Gtk.Label("Welcome to GhostBSD!", name="Header")
|
||||
label.set_property("height-request", 40)
|
||||
vBox.pack_start(label, False, False, 0)
|
||||
hBox = Gtk.HBox(False, 0, name="welcome")
|
||||
hBox.show()
|
||||
vBox.pack_end(hBox, True, True, 0)
|
||||
vBox2 = Gtk.VBox(False, 0)
|
||||
vBox2.show()
|
||||
label2 = Gtk.Label(name="slideText")
|
||||
label2.set_markup("Thank you for choosing GhostBSD. We hope you enjoy the BSD experience.\n\n"
|
||||
"We believe every computer operating system should be elegant, lightweight and secure. It should respect your privacy and give the user true freedom. GhostBSD makes FreeBSD desktop computing much easier.\n\n"
|
||||
"We want GhostBSD to work for you. So while your software is installing, this slideshow will introduce you to GhostBSD.")
|
||||
label2.set_justify(Gtk.Justification.LEFT)
|
||||
label2.set_line_wrap(True)
|
||||
# label2.set_max_width_chars(10)
|
||||
label2.set_alignment(0.0, 0.2)
|
||||
hBox2 = Gtk.HBox(False, 0, name="TransBox")
|
||||
hBox2.show()
|
||||
hBox.pack_start(hBox2, True, True, 0)
|
||||
hBox2.pack_start(label2, True, True, 30)
|
||||
label3 = Gtk.Label()
|
||||
hBox.pack_end(label3, True, True, 160)
|
||||
return vBox
|
||||
|
||||
def Software(self):
|
||||
vBox = Gtk.VBox(False, 0)
|
||||
vBox.show()
|
||||
label = Gtk.Label("Install more software ", name="Header")
|
||||
label.set_property("height-request", 40)
|
||||
vBox.pack_start(label, False, False, 0)
|
||||
hBox = Gtk.HBox(False, 0, name="software")
|
||||
hBox.show()
|
||||
vBox.pack_end(hBox, True, True, 0)
|
||||
label2 = Gtk.Label(name="slideText")
|
||||
label2.set_markup("Search, install, upgrade and uninstall software with the OctoPkg software manager.\n\n"
|
||||
"OctoPkg is a powerful tool to manage GhostBSD/FreeBSD software. It has a simple interface which consists of just 2 panels, a list of all available software packages including results of searches and a tab widget showing 6 useful tabs for information, files, transaction, output, news, and a quick help guide.\n\n"
|
||||
"There are over 25,000 software packages available to install.")
|
||||
label2.set_justify(Gtk.Justification.LEFT)
|
||||
label2.set_line_wrap(True)
|
||||
label2.set_alignment(0.1, 0.2)
|
||||
hBox2 = Gtk.HBox(False, 0, name="TransBox")
|
||||
hBox2.show()
|
||||
hBox.pack_start(hBox2, True, True, 0)
|
||||
hBox2.pack_start(label2, True, True, 30)
|
||||
label3 = Gtk.Label()
|
||||
hBox.pack_end(label3, True, True, 160)
|
||||
return vBox
|
||||
|
||||
def TheWeb(self):
|
||||
vBox = Gtk.VBox(False, 0)
|
||||
vBox.show()
|
||||
label = Gtk.Label("Make the most of the web", name="Header")
|
||||
label.set_property("height-request", 40)
|
||||
vBox.pack_start(label, False, False, 0)
|
||||
hBox = Gtk.HBox(False, 0, name="web")
|
||||
hBox.show()
|
||||
vBox.pack_end(hBox, True, True, 0)
|
||||
label2 = Gtk.Label(name="slideText")
|
||||
label2.set_markup("GhostBSD comes with Mozilla Firefox, the web browser used by millions of people around the world.\n\n"
|
||||
"Browse the web safely and privately, share your files, software and multimedia, send and receive e-mail and communicate with friends and family.\n\n"
|
||||
"Web browsers such as Chromium and Epiphany are easily installable.")
|
||||
label2.set_justify(Gtk.Justification.LEFT)
|
||||
label2.set_line_wrap(True)
|
||||
label2.set_alignment(0.1, 0.2)
|
||||
hBox2 = Gtk.HBox(False, 0, name="TransBox")
|
||||
hBox2.show()
|
||||
hBox.pack_start(hBox2, True, True, 0)
|
||||
hBox2.pack_start(label2, True, True, 30)
|
||||
label3 = Gtk.Label()
|
||||
hBox.pack_end(label3, True, True, 160)
|
||||
return vBox
|
||||
|
||||
def email(self):
|
||||
vBox = Gtk.VBox(False, 0)
|
||||
vBox.show()
|
||||
label = Gtk.Label("Make the most of the web", name="Header")
|
||||
label.set_property("height-request", 40)
|
||||
vBox.pack_start(label, False, False, 0)
|
||||
hBox = Gtk.HBox(False, 0, name="web")
|
||||
hBox.show()
|
||||
vBox.pack_end(hBox, True, True, 0)
|
||||
label2 = Gtk.Label(name="slideText")
|
||||
label2.set_markup("GhostBSD comes with Mozilla Firefox, the web browser used by millions of people around the world.\n\n"
|
||||
"Browse the web safely and privately, share your files, software and multimedia, send and receive e-mail and communicate with friends and family.\n\n"
|
||||
"Web browsers such as Chromium and Epiphany are easily installable.")
|
||||
label2.set_justify(Gtk.Justification.LEFT)
|
||||
label2.set_line_wrap(True)
|
||||
label2.set_alignment(0.1, 0.2)
|
||||
hBox2 = Gtk.HBox(False, 0, name="TransBox")
|
||||
hBox2.show()
|
||||
hBox.pack_start(hBox2, True, True, 0)
|
||||
hBox2.pack_start(label2, True, True, 30)
|
||||
label3 = Gtk.Label()
|
||||
hBox.pack_end(label3, True, True, 160)
|
||||
return vBox
|
||||
|
||||
def Photos(self):
|
||||
vBox = Gtk.VBox(False, 0)
|
||||
vBox.show()
|
||||
label = Gtk.Label(name="Header")
|
||||
label.set_markup('Organize, retouch and share your photos')
|
||||
label.set_property("height-request", 40)
|
||||
vBox.pack_start(label, False, False, 0)
|
||||
hBox = Gtk.HBox(False, 0, name="photo")
|
||||
hBox.show()
|
||||
vBox.pack_end(hBox, True, True, 0)
|
||||
label2 = Gtk.Label(name="slideText")
|
||||
label2.set_markup("With Shotwell it is really easy to organize and share your photos.\n\n"
|
||||
"Use the export option to copy your photos to a remote computer, iPod, a custom HTML gallery or to services such as Flickr, Facebook, PicasaWeb and more.\n\n"
|
||||
"For more advanced photos editing, Gimp is available for installation.")
|
||||
label2.set_justify(Gtk.Justification.LEFT)
|
||||
label2.set_line_wrap(True)
|
||||
label2.set_alignment(0.1, 0.2)
|
||||
hBox2 = Gtk.HBox(False, 0, name="TransBox")
|
||||
hBox2.show()
|
||||
hBox.pack_start(hBox2, True, True, 0)
|
||||
hBox2.pack_start(label2, True, True, 30)
|
||||
label3 = Gtk.Label()
|
||||
hBox.pack_end(label3, True, True, 160)
|
||||
return vBox
|
||||
|
||||
def MultiMedia(self):
|
||||
vBox = Gtk.VBox(False, 0)
|
||||
vBox.show()
|
||||
label = Gtk.Label("Play your movies and music", name="Header")
|
||||
label.set_property("height-request", 40)
|
||||
vBox.pack_start(label, False, False, 0)
|
||||
hBox = Gtk.HBox(False, 0, name="mutimedia")
|
||||
hBox.show()
|
||||
vBox.pack_end(hBox, True, True, 0)
|
||||
label2 = Gtk.Label(name="slideText")
|
||||
label2.set_markup("GhostBSD is ready to play videos and music from the web, CDs and DVDs.\n\n"
|
||||
"The Exaile audio player lets you organize your music and listen to Internet radio, podcasts and more, as well as synchronize your audio collection to a portable audio player.\n\n"
|
||||
"\nGnome MPlayer allows you to easily watch videos from your computer or DVD.")
|
||||
label2.set_justify(Gtk.Justification.LEFT)
|
||||
label2.set_line_wrap(True)
|
||||
label2.set_alignment(0.1, 0.2)
|
||||
hBox2 = Gtk.HBox(False, 0, name="TransBox")
|
||||
hBox2.show()
|
||||
hBox.pack_start(hBox2, True, True, 0)
|
||||
hBox2.pack_start(label2, True, True, 30)
|
||||
label3 = Gtk.Label()
|
||||
hBox.pack_end(label3, True, True, 160)
|
||||
return vBox
|
||||
|
||||
def communicate(self):
|
||||
vBox = Gtk.VBox(False, 0)
|
||||
vBox.show()
|
||||
label = Gtk.Label("Play your movies and music", name="Header")
|
||||
label.set_property("height-request", 40)
|
||||
vBox.pack_start(label, False, False, 0)
|
||||
hBox = Gtk.HBox(False, 0, name="communicate")
|
||||
hBox.show()
|
||||
vBox.pack_end(hBox, True, True, 0)
|
||||
label2 = Gtk.Label(name="slideText")
|
||||
label2.set_markup("GhostBSD is ready to play videos and music from the web, CDs and DVDs.\n\n"
|
||||
"The Exaile audio player lets you organize your music and listen to Internet radio, podcasts and more, as well as synchronize your audio collection to a portable audio player.\n\n"
|
||||
"\nGnome MPlayer allows you to easily watch videos from your computer or DVD.")
|
||||
label2.set_justify(Gtk.Justification.LEFT)
|
||||
label2.set_line_wrap(True)
|
||||
label2.set_alignment(0.1, 0.2)
|
||||
hBox2 = Gtk.HBox(False, 0, name="TransBox")
|
||||
hBox2.show()
|
||||
hBox.pack_start(hBox2, True, True, 0)
|
||||
hBox2.pack_start(label2, True, True, 30)
|
||||
label3 = Gtk.Label()
|
||||
hBox.pack_end(label3, True, True, 160)
|
||||
return vBox
|
||||
|
||||
def Help(self):
|
||||
vBox = Gtk.VBox(False, 0)
|
||||
vBox.show()
|
||||
label = Gtk.Label("Help & Support", name="Header")
|
||||
label.set_property("height-request", 40)
|
||||
vBox.pack_start(label, False, False, 0)
|
||||
hBox = Gtk.HBox(False, 0, name="help")
|
||||
hBox.show()
|
||||
vBox.pack_end(hBox, True, True, 0)
|
||||
label2 = Gtk.Label(name="slideText")
|
||||
label2.set_markup("Check out the forums for answers to all your GhostBSD questions.\n\n"
|
||||
"There's a good chance your question has already been answered and if not, you'll find volunteers eager to help.\n\n"
|
||||
"For more support options go to our <a href='http://www.ghostbsd.org/support'>support page</a>.")
|
||||
label2.set_justify(Gtk.Justification.LEFT)
|
||||
label2.set_line_wrap(True)
|
||||
label2.set_alignment(0.1, 0.2)
|
||||
hBox2 = Gtk.HBox(False, 0, name="TransBox")
|
||||
hBox2.show()
|
||||
hBox.pack_start(hBox2, True, True, 0)
|
||||
hBox2.pack_start(label2, True, True, 30)
|
||||
label3 = Gtk.Label()
|
||||
hBox.pack_end(label3, True, True, 160)
|
||||
return vBox
|
||||
|
||||
def SlideRight(self):
|
||||
if self.stack.get_visible_child() == self.welcome:
|
||||
self.stack.set_visible_child(self.software)
|
||||
elif self.stack.get_visible_child() == self.software:
|
||||
self.stack.set_visible_child(self.web)
|
||||
elif self.stack.get_visible_child() == self.web:
|
||||
self.stack.set_visible_child(self.photos)
|
||||
elif self.stack.get_visible_child() == self.photos:
|
||||
self.stack.set_visible_child(self.multimedia)
|
||||
elif self.stack.get_visible_child() == self.multimedia:
|
||||
self.stack.set_visible_child(self.help)
|
||||
elif self.stack.get_visible_child() == self.help:
|
||||
self.stack.set_visible_child(self.welcome)
|
||||
|
||||
def __init__(self):
|
||||
self.hBox = Gtk.HBox(False, 0)
|
||||
self.hBox.show()
|
||||
self.stack = Gtk.Stack()
|
||||
self.hBox.add(self.stack)
|
||||
# Adding slide self.grid in to stack
|
||||
self.welcome = self.Welcome()
|
||||
self.stack.add_named(self.welcome, "welcome")
|
||||
self.software = self.Software()
|
||||
self.stack.add_named(self.software, "software")
|
||||
self.web = self.TheWeb()
|
||||
self.stack.add_named(self.web, "web")
|
||||
self.photos = self.Photos()
|
||||
self.stack.add_named(self.photos, "photos")
|
||||
self.multimedia = self.MultiMedia()
|
||||
self.stack.add_named(self.multimedia, "multimedia")
|
||||
self.help = self.Help()
|
||||
self.stack.add_named(self.help, "help")
|
||||
self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT)
|
||||
self.stack.show()
|
||||
thr = threading.Thread(target=self.slidesThreading)
|
||||
thr.setDaemon(True)
|
||||
thr.start()
|
||||
|
||||
def get_slide(self):
|
||||
return self.hBox
|
||||
|
||||
def slidesThreading(self):
|
||||
while 1:
|
||||
sleep(60)
|
||||
GLib.idle_add(self.SlideRight)
|
||||
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
|
||||
def language_dictionary():
|
||||
langs = Popen('pc-sysinstall query-langs', shell=True, stdin=PIPE,
|
||||
stdout=PIPE, universal_newlines=True,
|
||||
close_fds=True).stdout.readlines()
|
||||
dictionary = {}
|
||||
for line in langs:
|
||||
lang_list = line.rstrip()
|
||||
lang_name = lang_list.partition(' ')[2]
|
||||
lang_code = lang_list.partition(' ')[0]
|
||||
dictionary[lang_name] = lang_code
|
||||
return dictionary
|
||||
|
||||
|
||||
def keyboard_dictionary():
|
||||
xkeyboard_layouts = Popen('pc-sysinstall xkeyboard-layouts', shell=True,
|
||||
stdout=PIPE,
|
||||
universal_newlines=True).stdout.readlines()
|
||||
dictionary = {}
|
||||
for line in xkeyboard_layouts:
|
||||
keyboard_list = list(filter(None, line.rstrip().split(' ')))
|
||||
kb_name = keyboard_list[1].strip()
|
||||
kb_layouts = keyboard_list[0].strip()
|
||||
kb_variant = None
|
||||
dictionary[kb_name] = {'layout': kb_layouts, 'variant': kb_variant}
|
||||
|
||||
xkeyboard_variants = Popen('pc-sysinstall xkeyboard-variants', shell=True,
|
||||
stdout=PIPE,
|
||||
universal_newlines=True).stdout.readlines()
|
||||
for line in xkeyboard_variants:
|
||||
xkb_variant = line.rstrip()
|
||||
kb_name = xkb_variant.partition(':')[2].strip()
|
||||
keyboard_list = list(filter
|
||||
(None, xkb_variant.partition(':')[0].split()))
|
||||
kb_layouts = keyboard_list[1].strip()
|
||||
kb_variant = keyboard_list[0].strip()
|
||||
dictionary[kb_name] = {'layout': kb_layouts, 'variant': kb_variant}
|
||||
return dictionary
|
||||
|
||||
|
||||
def keyboard_models():
|
||||
xkeyboard_models = Popen('pc-sysinstall xkeyboard-models', shell=True,
|
||||
stdout=PIPE,
|
||||
universal_newlines=True).stdout.readlines()
|
||||
dictionary = {}
|
||||
for line in xkeyboard_models:
|
||||
kbm_name = line.rstrip().partition(' ')[2]
|
||||
kbm_code = line.rstrip().partition(' ')[0]
|
||||
dictionary[kbm_name] = kbm_code
|
||||
return dictionary
|
||||
|
||||
|
||||
def timezone_dictionary():
|
||||
tz_list = Popen('pc-sysinstall list-tzones', shell=True,
|
||||
stdout=PIPE, universal_newlines=True).stdout.readlines()
|
||||
city_list = []
|
||||
dictionary = {}
|
||||
last_continent = ''
|
||||
for zone in tz_list:
|
||||
zone_list = zone.partition(':')[0].rstrip().split('/')
|
||||
continent = zone_list[0]
|
||||
if continent != last_continent:
|
||||
city_list = []
|
||||
if len(zone_list) == 3:
|
||||
city = zone_list[1] + '/' + zone_list[2]
|
||||
elif len(zone_list) == 4:
|
||||
city = zone_list[1] + '/' + zone_list[2] + '/' + zone_list[3]
|
||||
else:
|
||||
city = zone_list[1]
|
||||
city_list.append(city)
|
||||
dictionary[continent] = city_list
|
||||
last_continent = continent
|
||||
return dictionary
|
||||
@@ -0,0 +1,500 @@
|
||||
#!/usr/local/bin/python
|
||||
"""
|
||||
Copyright (c) 2014-2016, GhostBSD. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistribution's of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistribution's in binary form must reproduce the above
|
||||
copyright notice,this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
|
||||
from gi.repository import Gtk
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
from db_partition import zfs_disk_query, zfs_disk_size_query, bios_or_uefi
|
||||
|
||||
# Folder use pr the installer.
|
||||
tmp = "/tmp/.gbinstall/"
|
||||
|
||||
if not os.path.exists(tmp):
|
||||
os.makedirs(tmp)
|
||||
|
||||
logo = "/usr/local/lib/gbinstall/logo.png"
|
||||
memory = 'sysctl hw.physmem'
|
||||
|
||||
Part_label = '%sufs_config' % tmp
|
||||
part_schem = '%sscheme' % tmp
|
||||
boot_file = '%sboot' % tmp
|
||||
|
||||
ufs_dsk_list = []
|
||||
|
||||
|
||||
# Find if pasword contain only lower case and number
|
||||
def lowerCase(strg, search=re.compile(r'[^a-z]').search):
|
||||
return not bool(search(strg))
|
||||
|
||||
|
||||
# Find if pasword contain only upper case
|
||||
def upperCase(strg, search=re.compile(r'[^A-Z]').search):
|
||||
return not bool(search(strg))
|
||||
|
||||
|
||||
# Find if pasword contain only lower case and number
|
||||
def lowerandNunber(strg, search=re.compile(r'[^a-z0-9]').search):
|
||||
return not bool(search(strg))
|
||||
|
||||
|
||||
# Find if pasword contain only upper case and number
|
||||
def upperandNunber(strg, search=re.compile(r'[^A-Z0-9]').search):
|
||||
return not bool(search(strg))
|
||||
|
||||
|
||||
# Find if pasword contain only lower and upper case and
|
||||
def lowerUpperCase(strg, search=re.compile(r'[^a-zA-Z]').search):
|
||||
return not bool(search(strg))
|
||||
|
||||
|
||||
# Find if pasword contain only lower and upper case and
|
||||
def lowerUpperNumber(strg, search=re.compile(r'[^a-zA-Z0-9]').search):
|
||||
return not bool(search(strg))
|
||||
|
||||
|
||||
# Find if pasword contain only lowercase, uppercase numbers and some special character.
|
||||
def allCharacter(strg, search=re.compile(r'[^a-zA-Z0-9~\!@#\$%\^&\*_\+":;\'\-]').search):
|
||||
return not bool(search(strg))
|
||||
|
||||
|
||||
class use_ufs():
|
||||
def save_selection(self):
|
||||
disk_size = int(ufs_dsk_list[0].partition('-')[2].rstrip()) - 2
|
||||
swap_size = int(self.swap_entry.get_text())
|
||||
root_size = disk_size - swap_size
|
||||
if self.disk_encript is True:
|
||||
dgeli = '.eli'
|
||||
else:
|
||||
dgeli = ''
|
||||
pfile = open(Part_label, 'w')
|
||||
pfile.writelines('disk0=%s\n' % ufs_dsk_list[0].partition('-')[0].rstrip())
|
||||
if self.mirror is True:
|
||||
ufs_disk = ufs_dsk_list
|
||||
disk_len = len(ufs_disk) - 1
|
||||
num = 1
|
||||
mirror_dsk = ''
|
||||
while disk_len != 0:
|
||||
mirror_dsk += ufs_disk[num].partition('-')[0].rstrip() + " "
|
||||
print(mirror_dsk)
|
||||
num += 1
|
||||
disk_len -= 1
|
||||
pfile.writelines("mirror=%s\n" % mirror_dsk)
|
||||
pfile.writelines("mirrorlab=%s\n" % self.mirrorbl)
|
||||
else:
|
||||
pfile.writelines("#mirror=\n")
|
||||
pfile.writelines("#mirrorlab=\n")
|
||||
pfile.writelines('partition=ALL\n')
|
||||
pfile.writelines('partscheme=%s\n' % self.scheme)
|
||||
pfile.writelines('commitDiskPart\n\n')
|
||||
read = open(boot_file, 'r')
|
||||
line = read.readlines()
|
||||
boot = line[0].strip()
|
||||
if bios_or_uefi() == "UEFI":
|
||||
root_size = root_size - 100
|
||||
elif boot == 'GRUB':
|
||||
root_size = root_size - 1
|
||||
else:
|
||||
root_size = root_size - 1
|
||||
zfsPart = 'disk0-part=%s%s %s /\n' % (self.fs, dgeli, root_size)
|
||||
pfile.writelines(zfsPart)
|
||||
if swap_size != 0:
|
||||
pfile.writelines('disk0-part=SWAP%s %s none\n' % (dgeli, swap_size))
|
||||
if self.disk_encript is True:
|
||||
pfile.writelines('encpass=%s\n' % self.password.get_text())
|
||||
else:
|
||||
pfile.writelines('#encpass=None\n')
|
||||
pfile.writelines('commitDiskLabel\n')
|
||||
pfile.close()
|
||||
|
||||
def sheme_selection(self, combobox):
|
||||
model = combobox.get_model()
|
||||
index = combobox.get_active()
|
||||
data = model[index][0]
|
||||
self.scheme = data
|
||||
|
||||
def mirror_selection(self, combobox):
|
||||
model = combobox.get_model()
|
||||
index = combobox.get_active()
|
||||
data = model[index][0]
|
||||
self.mirrorbl = data
|
||||
|
||||
def on_check_mirror(self, widget):
|
||||
if widget.get_active():
|
||||
self.mirrorbl_box.set_sensitive(True)
|
||||
self.mirror = True
|
||||
else:
|
||||
self.mirrorbl_box.set_sensitive(False)
|
||||
self.mirror = False
|
||||
if self.mirror is False:
|
||||
self.mirrorTips.set_text("Please select one drive")
|
||||
if len(ufs_dsk_list) != 1:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(True)
|
||||
elif self.mirror is True:
|
||||
self.mirrorTips.set_text("Please select 2 drive for mirroring")
|
||||
if len(ufs_dsk_list) > 1:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
|
||||
def on_check(self, widget):
|
||||
if widget.get_active():
|
||||
self.zfs_four_k = True
|
||||
else:
|
||||
self.zfs_four_k = False
|
||||
|
||||
def on_check_encrypt(self, widget):
|
||||
if widget.get_active():
|
||||
self.password.set_sensitive(True)
|
||||
self.repassword.set_sensitive(True)
|
||||
self.disk_encript = True
|
||||
# self.swap_encrypt_check.set_active(True)
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.password.set_sensitive(False)
|
||||
self.repassword.set_sensitive(False)
|
||||
self.disk_encript = False
|
||||
# self.swap_encrypt_check.set_active(False)
|
||||
if self.mirror is False:
|
||||
if len(ufs_dsk_list) != 1:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(True)
|
||||
elif self.mirror is True:
|
||||
if len(ufs_dsk_list) > 1:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
|
||||
def on_check_swap_encrypt(self, widget):
|
||||
if widget.get_active():
|
||||
self.swap_encrypt = True
|
||||
else:
|
||||
self.swap_encrypt = False
|
||||
|
||||
def on_check_swap_mirror(self, widget):
|
||||
if widget.get_active():
|
||||
self.swap_mirror = True
|
||||
else:
|
||||
self.swap_mirror = False
|
||||
|
||||
def chosefs(self, combobox):
|
||||
model = combobox.get_model()
|
||||
index = combobox.get_active()
|
||||
data = model[index][0]
|
||||
self.fs = data
|
||||
|
||||
def __init__(self, button3):
|
||||
self.button3 = button3
|
||||
self.box1 = Gtk.VBox(False, 0)
|
||||
self.box1.show()
|
||||
box2 = Gtk.HBox(False, 0)
|
||||
self.box1.pack_start(box2, True, True, 0)
|
||||
box2.show()
|
||||
# Title
|
||||
Title = Gtk.Label("<b><span size='xx-large'>UFS Full Disk Configuration</span></b>")
|
||||
Title.set_use_markup(True)
|
||||
# Chose disk
|
||||
sw = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
|
||||
sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
|
||||
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
store = Gtk.TreeStore(str, str, str, 'gboolean')
|
||||
for disk in zfs_disk_query():
|
||||
dsk = disk.partition(':')[0].rstrip()
|
||||
dsk_name = disk.partition(':')[2].rstrip()
|
||||
dsk_size = zfs_disk_size_query(dsk).rstrip()
|
||||
store.append(None, [dsk, dsk_size, dsk_name, False])
|
||||
treeView = Gtk.TreeView(store)
|
||||
treeView.set_model(store)
|
||||
treeView.set_rules_hint(True)
|
||||
self.check_cell = Gtk.CellRendererToggle()
|
||||
self.check_cell.set_property('activatable', True)
|
||||
self.check_cell.connect('toggled', self.col1_toggled_cb, store)
|
||||
cell = Gtk.CellRendererText()
|
||||
column = Gtk.TreeViewColumn(None, cell, text=0)
|
||||
column_header = Gtk.Label('Disk')
|
||||
column_header.set_use_markup(True)
|
||||
column_header.show()
|
||||
column.set_widget(column_header)
|
||||
column.set_sort_column_id(0)
|
||||
cell2 = Gtk.CellRendererText()
|
||||
column2 = Gtk.TreeViewColumn(None, cell2, text=0)
|
||||
column_header2 = Gtk.Label('Size(MB)')
|
||||
column_header2.set_use_markup(True)
|
||||
column_header2.show()
|
||||
column2.set_widget(column_header2)
|
||||
cell3 = Gtk.CellRendererText()
|
||||
column3 = Gtk.TreeViewColumn(None, cell3, text=0)
|
||||
column_header3 = Gtk.Label('Name')
|
||||
column_header3.set_use_markup(True)
|
||||
column_header3.show()
|
||||
column3.set_widget(column_header3)
|
||||
column1 = Gtk.TreeViewColumn("Check", self.check_cell)
|
||||
column1.add_attribute(self.check_cell, "active", 3)
|
||||
column.set_attributes(cell, text=0)
|
||||
column2.set_attributes(cell2, text=1)
|
||||
column3.set_attributes(cell3, text=2)
|
||||
treeView.append_column(column1)
|
||||
treeView.append_column(column)
|
||||
treeView.append_column(column2)
|
||||
treeView.append_column(column3)
|
||||
tree_selection = treeView.get_selection()
|
||||
tree_selection.set_mode(Gtk.SelectionMode.SINGLE)
|
||||
sw.add(treeView)
|
||||
sw.show()
|
||||
self.mirrorTips = Gtk.Label('Please select one drive')
|
||||
self.mirrorTips.set_justify(Gtk.Justification.LEFT)
|
||||
self.mirrorTips.set_alignment(0.01, 0.5)
|
||||
self.mirror = False
|
||||
mirror_check = Gtk.CheckButton('Disk Mirror')
|
||||
mirror_check.connect("toggled", self.on_check_mirror)
|
||||
self.mirrorbl_box = Gtk.ComboBoxText()
|
||||
self.mirrorbl_box.append_text("load")
|
||||
self.mirrorbl_box.append_text("prefer")
|
||||
self.mirrorbl_box.append_text("round-robin")
|
||||
self.mirrorbl_box.append_text("split")
|
||||
self.mirrorbl_box.connect('changed', self.mirror_selection)
|
||||
self.mirrorbl_box.set_active(0)
|
||||
self.mirrorbl_box.set_sensitive(False)
|
||||
self.mirrorbl = 'load'
|
||||
# Creating MBR or GPT drive
|
||||
label = Gtk.Label('<b>Partition Scheme</b>')
|
||||
label.set_use_markup(True)
|
||||
# Adding a combo box to selecting MBR or GPT sheme.
|
||||
self.scheme = 'GPT'
|
||||
shemebox = Gtk.ComboBoxText()
|
||||
shemebox.append_text("GPT")
|
||||
shemebox.append_text("MBR")
|
||||
shemebox.connect('changed', self.sheme_selection)
|
||||
shemebox.set_active(0)
|
||||
# Swap Size
|
||||
ram = Popen(memory, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT,
|
||||
universal_newlines=True, close_fds=True)
|
||||
mem = ram.stdout.read()
|
||||
swap = 512
|
||||
swp_size_label = Gtk.Label('<b>Swap Size(MB)</b>')
|
||||
swp_size_label.set_use_markup(True)
|
||||
self.swap_entry = Gtk.Entry()
|
||||
self.swap_entry.set_text(str(swap))
|
||||
self.swap_entry.connect('changed', self.digit_only)
|
||||
# Swap encription
|
||||
self.swap_encrypt = False
|
||||
self.swap_encrypt_check = Gtk.CheckButton("Encrypt Swap")
|
||||
self.swap_encrypt_check.connect("toggled", self.on_check_swap_encrypt)
|
||||
# Swap mirror
|
||||
self.swap_mirror = False
|
||||
swap_mirror_check = Gtk.CheckButton("Mirror Swap")
|
||||
swap_mirror_check.connect("toggled", self.on_check_swap_mirror)
|
||||
# GELI Disk encription
|
||||
self.disk_encript = False
|
||||
encrypt_check = Gtk.CheckButton("Encrypt Disk")
|
||||
encrypt_check.connect("toggled", self.on_check_encrypt)
|
||||
encrypt_check.set_sensitive(True)
|
||||
# password
|
||||
self.passwd_label = Gtk.Label("Password")
|
||||
self.password = Gtk.Entry()
|
||||
self.password.set_sensitive(False)
|
||||
self.password.set_visibility(False)
|
||||
self.password.connect("changed", self.passwdstrength)
|
||||
self.strenght_label = Gtk.Label()
|
||||
self.strenght_label.set_alignment(0.1, 0.5)
|
||||
self.vpasswd_label = Gtk.Label("Verify it")
|
||||
self.repassword = Gtk.Entry()
|
||||
self.repassword.set_sensitive(False)
|
||||
self.repassword.set_visibility(False)
|
||||
self.repassword.connect("changed", self.passwdVerification)
|
||||
# set image for password matching
|
||||
fslabel = Gtk.Label("File System:")
|
||||
self.fstype = Gtk.ComboBoxText()
|
||||
self.fstype.append_text('UFS')
|
||||
self.fstype.append_text('UFS+S')
|
||||
self.fstype.append_text('UFS+J')
|
||||
self.fstype.append_text('UFS+SUJ')
|
||||
self.fstype.set_active(3)
|
||||
self.fstype.connect("changed", self.chosefs)
|
||||
self.fs = "UFS+SUJ"
|
||||
grid = Gtk.Grid()
|
||||
grid.set_row_spacing(10)
|
||||
# grid.set_column_homogeneous(True)
|
||||
# grid.set_row_homogeneous(True)
|
||||
grid.attach(Title, 0, 0, 9, 2)
|
||||
grid.attach(mirror_check, 0, 2, 1, 1)
|
||||
grid.attach(self.mirrorbl_box, 1, 2, 1, 1)
|
||||
grid.attach(label, 0, 9, 2, 1)
|
||||
grid.attach(shemebox, 2, 9, 1, 1)
|
||||
grid.attach(self.mirrorTips, 1, 3, 8, 1)
|
||||
grid.attach(sw, 0, 4, 9, 4)
|
||||
grid.attach(fslabel, 5, 9, 2, 1)
|
||||
grid.attach(self.fstype, 7, 9, 1, 1)
|
||||
grid.attach(swp_size_label, 5, 2, 2, 1)
|
||||
grid.attach(self.swap_entry, 7, 2, 1, 1)
|
||||
# grid.attach(self.swap_encrypt_check, 9, 15, 11, 12)
|
||||
# grid.attach(swap_mirror_check, 9, 15, 11, 12)
|
||||
# grid.attach(encrypt_check, 1, 9, 2, 1)
|
||||
# grid.attach(self.passwd_label, 1, 10, 1, 1)
|
||||
# grid.attach(self.password, 2, 10, 2, 1)
|
||||
# grid.attach(self.strenght_label, 4, 10, 2, 1)
|
||||
# grid.attach(self.vpasswd_label, 1, 11, 1, 1)
|
||||
# grid.attach(self.repassword, 2, 11, 2, 1)
|
||||
# grid.attach(self.img, 4, 11, 2, 1)
|
||||
box2.pack_start(grid, True, True, 10)
|
||||
return
|
||||
|
||||
def get_model(self):
|
||||
del ufs_dsk_list[:]
|
||||
return self.box1
|
||||
|
||||
def digit_only(self, *args):
|
||||
text = self.swap_entry.get_text().strip()
|
||||
self.swap_entry.set_text(''.join([i for i in text if i in '0123456789']))
|
||||
|
||||
def col1_toggled_cb(self, cell, path, model):
|
||||
model[path][3] = not model[path][3]
|
||||
if model[path][3] is False:
|
||||
ufs_dsk_list.remove(model[path][0] + "-" + model[path][1])
|
||||
if self.mirror is False:
|
||||
if len(ufs_dsk_list) != 1:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(True)
|
||||
elif self.mirror is True:
|
||||
if len(ufs_dsk_list) > 1:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
ufs_dsk_list.extend([model[path][0] + "-" + model[path][1]])
|
||||
if self.mirror is False:
|
||||
if len(ufs_dsk_list) != 1:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(True)
|
||||
elif self.mirror is True:
|
||||
if len(ufs_dsk_list) > 1:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
print(ufs_dsk_list)
|
||||
return
|
||||
|
||||
def passwdstrength(self, widget):
|
||||
passwd = self.password.get_text()
|
||||
if len(passwd) <= 4:
|
||||
self.strenght_label.set_text("Super Weak")
|
||||
elif len(passwd) <= 8:
|
||||
if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
|
||||
self.strenght_label.set_text("Super Weak")
|
||||
elif lowerandNunber(passwd):
|
||||
self.strenght_label.set_text("Very Weak")
|
||||
elif upperandNunber(passwd):
|
||||
self.strenght_label.set_text("Very Weak")
|
||||
elif lowerUpperCase(passwd):
|
||||
self.strenght_label.set_text("Very Weak")
|
||||
elif lowerUpperNumber(passwd):
|
||||
self.strenght_label.set_text("Fairly Weak")
|
||||
elif allCharacter(passwd):
|
||||
self.strenght_label.set_text("Weak")
|
||||
elif len(passwd) <= 12:
|
||||
if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
|
||||
self.strenght_label.set_text("Very Weak")
|
||||
elif lowerandNunber(passwd):
|
||||
self.strenght_label.set_text("Fairly Weak")
|
||||
elif upperandNunber(passwd):
|
||||
self.strenght_label.set_text("Fairly Weak")
|
||||
elif lowerUpperCase(passwd):
|
||||
self.strenght_label.set_text("Fairly Weak")
|
||||
elif lowerUpperNumber(passwd):
|
||||
self.strenght_label.set_text("Weak")
|
||||
elif allCharacter(passwd):
|
||||
self.strenght_label.set_text("Strong")
|
||||
elif len(passwd) <= 16:
|
||||
if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
|
||||
self.strenght_label.set_text("Fairly Weak")
|
||||
elif lowerandNunber(passwd):
|
||||
self.strenght_label.set_text("Weak")
|
||||
elif upperandNunber(passwd):
|
||||
self.strenght_label.set_text("Weak")
|
||||
elif lowerUpperCase(passwd):
|
||||
self.strenght_label.set_text("Weak")
|
||||
elif lowerUpperNumber(passwd):
|
||||
self.strenght_label.set_text("Strong")
|
||||
elif allCharacter(passwd):
|
||||
self.strenght_label.set_text("Fairly Strong")
|
||||
elif len(passwd) <= 20:
|
||||
if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
|
||||
self.strenght_label.set_text("Weak")
|
||||
elif lowerandNunber(passwd):
|
||||
self.strenght_label.set_text("Strong")
|
||||
elif upperandNunber(passwd):
|
||||
self.strenght_label.set_text("Strong")
|
||||
elif lowerUpperCase(passwd):
|
||||
self.strenght_label.set_text("Strong")
|
||||
elif lowerUpperNumber(passwd):
|
||||
self.strenght_label.set_text("Fairly Strong")
|
||||
elif allCharacter(passwd):
|
||||
self.strenght_label.set_text("Very Strong")
|
||||
elif len(passwd) <= 24:
|
||||
if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
|
||||
self.strenght_label.set_text("Strong")
|
||||
elif lowerandNunber(passwd):
|
||||
self.strenght_label.set_text("Fairly Strong")
|
||||
elif upperandNunber(passwd):
|
||||
self.strenght_label.set_text("Fairly Strong")
|
||||
elif lowerUpperCase(passwd):
|
||||
self.strenght_label.set_text("Fairly Strong")
|
||||
elif lowerUpperNumber(passwd):
|
||||
self.strenght_label.set_text("Very Strong")
|
||||
elif allCharacter(passwd):
|
||||
self.strenght_label.set_text("Super Strong")
|
||||
elif len(passwd) > 24:
|
||||
if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
|
||||
self.strenght_label.set_text("Fairly Strong")
|
||||
else:
|
||||
self.strenght_label.set_text("Super Strong")
|
||||
|
||||
def passwdVerification(self, widget):
|
||||
if self.password.get_text() == self.repassword.get_text():
|
||||
self.img.set_from_stock(Gtk.STOCK_YES, 10)
|
||||
if self.mirror == "none":
|
||||
if len(ufs_dsk_list) != 1:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(True)
|
||||
elif self.mirror == "mirror":
|
||||
if len(ufs_dsk_list) > 1:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.img.set_from_stock(Gtk.STOCK_NO, 10)
|
||||
self.button3.set_sensitive(False)
|
||||
@@ -0,0 +1,689 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright (c) 2014-2016, GhostBSD. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistribution's of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistribution's in binary form must reproduce the above
|
||||
copyright notice,this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
|
||||
from gi.repository import Gtk
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
from db_partition import zfs_disk_query, zfs_disk_size_query, bios_or_uefi
|
||||
|
||||
# Folder use pr the installer.
|
||||
tmp = "/tmp/.gbinstall/"
|
||||
installer = "/usr/local/lib/gbinstall/"
|
||||
query = "sh /usr/local/lib/gbinstall/backend-query/"
|
||||
if not os.path.exists(tmp):
|
||||
os.makedirs(tmp)
|
||||
|
||||
logo = "/usr/local/lib/gbinstall/logo.png"
|
||||
memory = 'sysctl hw.physmem'
|
||||
auto = '%sauto' % tmp
|
||||
disk_info = '%sdisk-info.sh' % query
|
||||
disk_file = '%sdisk' % tmp
|
||||
dslice = '%sslice' % tmp
|
||||
Part_label = '%szfs_config' % tmp
|
||||
part_schem = '%sscheme' % tmp
|
||||
boot_file = '%sboot' % tmp
|
||||
|
||||
global zfs_dsk_list
|
||||
zfs_dsk_list = []
|
||||
|
||||
|
||||
# Find if pasword contain only lower case and number
|
||||
def lowerCase(strg, search=re.compile(r'[^a-z]').search):
|
||||
return not bool(search(strg))
|
||||
|
||||
|
||||
# Find if pasword contain only upper case
|
||||
def upperCase(strg, search=re.compile(r'[^A-Z]').search):
|
||||
return not bool(search(strg))
|
||||
|
||||
|
||||
# Find if pasword contain only lower case and number
|
||||
def lowerandNunber(strg, search=re.compile(r'[^a-z0-9]').search):
|
||||
return not bool(search(strg))
|
||||
|
||||
|
||||
# Find if pasword contain only upper case and number
|
||||
def upperandNunber(strg, search=re.compile(r'[^A-Z0-9]').search):
|
||||
return not bool(search(strg))
|
||||
|
||||
|
||||
# Find if pasword contain only lower and upper case and
|
||||
def lowerUpperCase(strg, search=re.compile(r'[^a-zA-Z]').search):
|
||||
return not bool(search(strg))
|
||||
|
||||
|
||||
# Find if pasword contain only lower and upper case and
|
||||
def lowerUpperNumber(strg, search=re.compile(r'[^a-zA-Z0-9]').search):
|
||||
return not bool(search(strg))
|
||||
|
||||
|
||||
# Find if pasword contain only lowercase, uppercase numbers
|
||||
# and some special character.
|
||||
def allCharacter(strg, search=re.compile(r'[^a-zA-Z0-9~\!@#\$%\^&\*_\+":;\'\-]').search):
|
||||
return not bool(search(strg))
|
||||
|
||||
|
||||
class ZFS():
|
||||
def save_selection(self):
|
||||
SIZE = int(zfs_dsk_list[0].partition('-')[2].rstrip()) - 2
|
||||
SWAP = int(self.swap_entry.get_text())
|
||||
ZFS_NUM = SIZE - SWAP
|
||||
if self.disk_encript is True:
|
||||
dgeli = '.eli'
|
||||
else:
|
||||
dgeli = ''
|
||||
pfile = open(Part_label, 'w')
|
||||
if self.zpool is True:
|
||||
pfile.writelines("zpoolName=%s\n" % self.pool.get_text())
|
||||
else:
|
||||
pfile.writelines("#zpoolName=None\n")
|
||||
if self.zfs_four_k is True:
|
||||
pfile.writelines('zfsForce4k=YES\n\n')
|
||||
else:
|
||||
pfile.writelines('#zfsForce4k=No\n\n')
|
||||
pfile.writelines('disk0=%s\n' % zfs_dsk_list[0].partition('-')[0].rstrip())
|
||||
pfile.writelines('partition=ALL\n')
|
||||
pfile.writelines('partscheme=%s\n' % self.scheme)
|
||||
pfile.writelines('commitDiskPart\n\n')
|
||||
if self.poolType == 'none':
|
||||
pool_disk = '\n'
|
||||
else:
|
||||
ZFS_disk = zfs_dsk_list
|
||||
disk_len = len(ZFS_disk) - 1
|
||||
num = 1
|
||||
mirror_dsk = ''
|
||||
while disk_len != 0:
|
||||
mirror_dsk += ' ' + ZFS_disk[num].partition('-')[0].rstrip()
|
||||
print(mirror_dsk)
|
||||
num += 1
|
||||
disk_len -= 1
|
||||
pool_disk = ' (%s:%s)\n' % (self.poolType, mirror_dsk)
|
||||
read = open(boot_file, 'r')
|
||||
line = read.readlines()
|
||||
boot = line[0].strip()
|
||||
if bios_or_uefi() == "UEFI":
|
||||
ZFS_NUM = ZFS_NUM - 100
|
||||
elif boot == 'GRUB':
|
||||
ZFS_NUM = ZFS_NUM - 1
|
||||
else:
|
||||
ZFS_NUM = ZFS_NUM - 1
|
||||
zfslayout = "/(compress=lz4|atime=off),/root(compress=lz4)," \
|
||||
"/tmp(compress=lz4),/usr(canmount=off|mountpoint=none)," \
|
||||
"/usr/home(compress=lz4),/usr/jails(compress=lz4)," \
|
||||
"/usr/obj(compress=lz4),/usr/ports(compress=lz4)," \
|
||||
"/usr/src(compress=lz4)," \
|
||||
"/var(canmount=off|atime=on|mountpoint=none)," \
|
||||
"/var/audit(compress=lz4),/var/log(compress=lz4)," \
|
||||
"/var/mail(compress=lz4),/var/tmp(compress=lz4)"
|
||||
zfsPart = 'disk0-part=ZFS%s %s %s%s' % (dgeli, ZFS_NUM, zfslayout,
|
||||
pool_disk)
|
||||
pfile.writelines(zfsPart)
|
||||
if SWAP != 0:
|
||||
pfile.writelines('disk0-part=SWAP%s %s none\n' % ('', SWAP))
|
||||
if self.disk_encript is True:
|
||||
pfile.writelines('encpass=%s\n' % self.password.get_text())
|
||||
else:
|
||||
pfile.writelines('#encpass=None\n')
|
||||
pfile.writelines('commitDiskLabel\n')
|
||||
pfile.close()
|
||||
|
||||
def sheme_selection(self, combobox):
|
||||
model = combobox.get_model()
|
||||
index = combobox.get_active()
|
||||
data = model[index][0]
|
||||
self.scheme = data.partition(':')[0]
|
||||
|
||||
def mirror_selection(self, combobox):
|
||||
model = combobox.get_model()
|
||||
index = combobox.get_active()
|
||||
mirror_mesage = " (select the smallest disk first)"
|
||||
data = model[index][0]
|
||||
self.mirror = data
|
||||
if self.mirror == "single disk":
|
||||
self.poolType = 'none'
|
||||
self.mirrorTips.set_text("Please select one drive")
|
||||
if len(zfs_dsk_list) != 1:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(True)
|
||||
elif self.mirror == "2 disk mirror":
|
||||
self.poolType = 'mirror'
|
||||
mir_msg1 = f"Please select 2 drive for mirroring{mirror_mesage}"
|
||||
self.mirrorTips.set_text(mir_msg1)
|
||||
if len(zfs_dsk_list) == 2:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "3 disk raidz1":
|
||||
self.poolType = 'raidz1'
|
||||
self.mirrorTips.set_text("Please select 3 drive for raidz1" + mirror_mesage)
|
||||
if len(zfs_dsk_list) == 3:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "4 disk raidz2":
|
||||
self.poolType = 'raidz2'
|
||||
self.mirrorTips.set_text("Please select 4 drive for raidz2" + mirror_mesage)
|
||||
if len(zfs_dsk_list) == 4:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "5 disk raidz3":
|
||||
self.poolType = 'raidz3'
|
||||
self.mirrorTips.set_text("Please select 5 drive for raidz3" + mirror_mesage)
|
||||
if len(zfs_dsk_list) == 5:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "2+ disk stripe":
|
||||
self.poolType = 'stripe'
|
||||
self.mirrorTips.set_text("Please select 2 or more drive for stripe" + mirror_mesage)
|
||||
if len(zfs_dsk_list) >= 2:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
|
||||
def on_check_poll(self, widget):
|
||||
if widget.get_active():
|
||||
self.pool.set_sensitive(True)
|
||||
self.zpool = True
|
||||
else:
|
||||
self.pool.set_sensitive(False)
|
||||
self.zpool = False
|
||||
|
||||
def on_check(self, widget):
|
||||
if widget.get_active():
|
||||
self.zfs_four_k = True
|
||||
else:
|
||||
self.zfs_four_k = False
|
||||
|
||||
def on_check_encrypt(self, widget):
|
||||
if widget.get_active():
|
||||
self.password.set_sensitive(True)
|
||||
self.repassword.set_sensitive(True)
|
||||
self.disk_encript = True
|
||||
# self.swap_encrypt_check.set_active(True)
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.password.set_sensitive(False)
|
||||
self.repassword.set_sensitive(False)
|
||||
self.disk_encript = False
|
||||
# self.swap_encrypt_check.set_active(False)
|
||||
if self.mirror == "single disk":
|
||||
if len(zfs_dsk_list) != 1:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(True)
|
||||
elif self.mirror == "2 disk mirror":
|
||||
if len(zfs_dsk_list) == 2:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "3 disk raidz1":
|
||||
if len(zfs_dsk_list) == 3:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "4 disk raidz2":
|
||||
if len(zfs_dsk_list) == 4:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "5 disk raidz3":
|
||||
if len(zfs_dsk_list) == 5:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "2+ disk stripe":
|
||||
if len(zfs_dsk_list) >= 2:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
|
||||
def on_check_swap_encrypt(self, widget):
|
||||
if widget.get_active():
|
||||
self.swap_encrypt = True
|
||||
else:
|
||||
self.swap_encrypt = False
|
||||
|
||||
def on_check_swap_mirror(self, widget):
|
||||
if widget.get_active():
|
||||
self.swap_mirror = True
|
||||
else:
|
||||
self.swap_mirror = False
|
||||
|
||||
def __init__(self, button3):
|
||||
self.button3 = button3
|
||||
self.box1 = Gtk.VBox(False, 0)
|
||||
self.box1.show()
|
||||
box2 = Gtk.HBox(False, 0)
|
||||
self.box1.pack_start(box2, True, True, 0)
|
||||
box2.show()
|
||||
# Title
|
||||
Title = Gtk.Label("<b><span size='xx-large'>ZFS Configuration</span></b>")
|
||||
Title.set_use_markup(True)
|
||||
# Chose disk
|
||||
sw = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
|
||||
sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
|
||||
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
self.store = Gtk.TreeStore(str, str, str, 'gboolean')
|
||||
for disk in zfs_disk_query():
|
||||
dsk = disk.partition(':')[0].rstrip()
|
||||
dsk_name = disk.partition(':')[2].rstrip()
|
||||
dsk_size = zfs_disk_size_query(dsk).rstrip()
|
||||
self.store.append(None, [dsk, dsk_size, dsk_name, False])
|
||||
treeView = Gtk.TreeView(self.store)
|
||||
treeView.set_model(self.store)
|
||||
treeView.set_rules_hint(True)
|
||||
self.check_cell = Gtk.CellRendererToggle()
|
||||
self.check_cell.set_property('activatable', True)
|
||||
self.check_cell.connect('toggled', self.col1_toggled_cb, self.store)
|
||||
cell = Gtk.CellRendererText()
|
||||
column = Gtk.TreeViewColumn(None, cell, text=0)
|
||||
column_header = Gtk.Label('Disk')
|
||||
column_header.set_use_markup(True)
|
||||
column_header.show()
|
||||
column.set_widget(column_header)
|
||||
column.set_sort_column_id(0)
|
||||
cell2 = Gtk.CellRendererText()
|
||||
column2 = Gtk.TreeViewColumn(None, cell2, text=0)
|
||||
column_header2 = Gtk.Label('Size(MB)')
|
||||
column_header2.set_use_markup(True)
|
||||
column_header2.show()
|
||||
column2.set_widget(column_header2)
|
||||
cell3 = Gtk.CellRendererText()
|
||||
column3 = Gtk.TreeViewColumn(None, cell3, text=0)
|
||||
column_header3 = Gtk.Label('Name')
|
||||
column_header3.set_use_markup(True)
|
||||
column_header3.show()
|
||||
column3.set_widget(column_header3)
|
||||
column1 = Gtk.TreeViewColumn("Check", self.check_cell)
|
||||
column1.add_attribute(self.check_cell, "active", 3)
|
||||
column.set_attributes(cell, text=0)
|
||||
column2.set_attributes(cell2, text=1)
|
||||
column3.set_attributes(cell3, text=2)
|
||||
treeView.append_column(column1)
|
||||
treeView.append_column(column)
|
||||
treeView.append_column(column2)
|
||||
treeView.append_column(column3)
|
||||
tree_selection = treeView.get_selection()
|
||||
tree_selection.set_mode(Gtk.SelectionMode.SINGLE)
|
||||
sw.add(treeView)
|
||||
sw.show()
|
||||
self.mirrorTips = Gtk.Label('Please select one drive')
|
||||
self.mirrorTips.set_justify(Gtk.Justification.LEFT)
|
||||
self.mirrorTips.set_alignment(0.01, 0.5)
|
||||
# Mirro, raidz and stripe
|
||||
self.mirror = 'none'
|
||||
mirror_label = Gtk.Label('<b>Pool Type</b>')
|
||||
mirror_label.set_use_markup(True)
|
||||
mirror_box = Gtk.ComboBoxText()
|
||||
mirror_box.append_text("single disk")
|
||||
mirror_box.append_text("2 disk mirror")
|
||||
mirror_box.append_text("3 disk raidz1")
|
||||
mirror_box.append_text("4 disk raidz2")
|
||||
mirror_box.append_text("5 disk raidz3")
|
||||
mirror_box.append_text("2+ disk stripe")
|
||||
mirror_box.connect('changed', self.mirror_selection)
|
||||
mirror_box.set_active(0)
|
||||
|
||||
# Pool Name
|
||||
self.zpool = False
|
||||
pool_check = Gtk.CheckButton('Pool Name')
|
||||
pool_check.connect("toggled", self.on_check_poll)
|
||||
self.pool = Gtk.Entry()
|
||||
self.pool.set_text('tank')
|
||||
self.pool.set_sensitive(False)
|
||||
# Creating MBR or GPT drive
|
||||
label = Gtk.Label('<b>Partition Scheme</b>')
|
||||
label.set_use_markup(True)
|
||||
# Adding a combo box to selecting MBR or GPT sheme.
|
||||
self.scheme = 'GPT'
|
||||
shemebox = Gtk.ComboBoxText()
|
||||
shemebox.append_text("GPT")
|
||||
shemebox.append_text("MBR")
|
||||
shemebox.connect('changed', self.sheme_selection)
|
||||
shemebox.set_active(0)
|
||||
# Force 4k Sectors
|
||||
self.zfs_four_k = "True"
|
||||
zfs4kcheck = Gtk.CheckButton("Force ZFS 4k block size")
|
||||
zfs4kcheck.connect("toggled", self.on_check)
|
||||
zfs4kcheck.set_active(True)
|
||||
# Swap Size
|
||||
ram = Popen(memory, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT,
|
||||
universal_newlines=True, close_fds=True)
|
||||
mem = ram.stdout.read()
|
||||
swap = 512
|
||||
swp_size_label = Gtk.Label('<b>Swap Size(MB)</b>')
|
||||
swp_size_label.set_use_markup(True)
|
||||
self.swap_entry = Gtk.Entry()
|
||||
self.swap_entry.set_text(str(swap))
|
||||
self.swap_entry.connect('changed', self.digit_only)
|
||||
# Swap encription
|
||||
self.swap_encrypt = False
|
||||
self.swap_encrypt_check = Gtk.CheckButton("Encrypt Swap")
|
||||
self.swap_encrypt_check.connect("toggled", self.on_check_swap_encrypt)
|
||||
# Swap mirror
|
||||
self.swap_mirror = False
|
||||
swap_mirror_check = Gtk.CheckButton("Mirror Swap")
|
||||
swap_mirror_check.connect("toggled", self.on_check_swap_mirror)
|
||||
# GELI Disk encription
|
||||
self.disk_encript = False
|
||||
encrypt_check = Gtk.CheckButton("Encrypt Disk")
|
||||
encrypt_check.connect("toggled", self.on_check_encrypt)
|
||||
encrypt_check.set_sensitive(True)
|
||||
# password
|
||||
self.passwd_label = Gtk.Label("Password")
|
||||
self.password = Gtk.Entry()
|
||||
self.password.set_sensitive(False)
|
||||
self.password.set_visibility(False)
|
||||
self.password.connect("changed", self.passwdstrength)
|
||||
self.strenght_label = Gtk.Label()
|
||||
self.strenght_label.set_alignment(0.1, 0.5)
|
||||
self.vpasswd_label = Gtk.Label("Verify it")
|
||||
self.repassword = Gtk.Entry()
|
||||
self.repassword.set_sensitive(False)
|
||||
self.repassword.set_visibility(False)
|
||||
self.repassword.connect("changed", self.passwdVerification)
|
||||
# set image for password matching
|
||||
self.img = Gtk.Image()
|
||||
self.img.set_alignment(0.2, 0.5)
|
||||
# table = Gtk.Table(12, 12, True)
|
||||
grid = Gtk.Grid()
|
||||
grid.set_row_spacing(10)
|
||||
# grid.set_column_homogeneous(True)
|
||||
# grid.set_row_homogeneous(True)
|
||||
grid.attach(Title, 1, 0, 8, 2)
|
||||
grid.attach(mirror_label, 1, 2, 1, 1)
|
||||
grid.attach(mirror_box, 2, 2, 1, 1)
|
||||
# grid.attach(label, 6, 2, 2, 1)
|
||||
# grid.attach(shemebox, 8, 2, 1, 1)
|
||||
grid.attach(self.mirrorTips, 1, 3, 8, 1)
|
||||
grid.attach(sw, 1, 4, 8, 4)
|
||||
grid.attach(pool_check, 5, 9, 2, 1)
|
||||
grid.attach(self.pool, 7, 9, 2, 1)
|
||||
grid.attach(zfs4kcheck, 1, 9, 3, 1)
|
||||
grid.attach(swp_size_label, 5, 2, 2, 1)
|
||||
grid.attach(self.swap_entry, 7, 2, 2, 1)
|
||||
# grid.attach(self.swap_encrypt_check, 9, 15, 11, 12)
|
||||
# grid.attach(swap_mirror_check, 9, 15, 11, 12)
|
||||
# grid.attach(encrypt_check, 1, 9, 2, 1)
|
||||
# grid.attach(self.passwd_label, 1, 10, 1, 1)
|
||||
# grid.attach(self.password, 2, 10, 2, 1)
|
||||
# grid.attach(self.strenght_label, 4, 10, 2, 1)
|
||||
# grid.attach(self.vpasswd_label, 1, 11, 1, 1)
|
||||
# grid.attach(self.repassword, 2, 11, 2, 1)
|
||||
# grid.attach(self.img, 4, 11, 2, 1)
|
||||
box2.pack_start(grid, True, True, 10)
|
||||
return
|
||||
|
||||
def get_model(self):
|
||||
return self.box1
|
||||
|
||||
def digit_only(self, *args):
|
||||
text = self.swap_entry.get_text().strip()
|
||||
self.swap_entry.set_text(''.join([i for i in text if i in '0123456789']))
|
||||
|
||||
def check_if_small_disk(self, size):
|
||||
if len(zfs_dsk_list) != 0:
|
||||
for line in zfs_dsk_list:
|
||||
if int(line.partition('-')[2]) > int(size):
|
||||
returns = True
|
||||
break
|
||||
else:
|
||||
returns = False
|
||||
else:
|
||||
returns = False
|
||||
return returns
|
||||
|
||||
def col1_toggled_cb(self, cell, path, model):
|
||||
model[path][3] = not model[path][3]
|
||||
if model[path][3] is False:
|
||||
zfs_dsk_list.remove(model[path][0] + "-" + model[path][1])
|
||||
if self.mirror == "single disk":
|
||||
if len(zfs_dsk_list) != 1:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(True)
|
||||
elif self.mirror == "2 disk mirror":
|
||||
if len(zfs_dsk_list) == 2:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "3 disk raidz1":
|
||||
if len(zfs_dsk_list) == 3:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "4 disk raidz2":
|
||||
if len(zfs_dsk_list) == 4:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "5 disk raidz3":
|
||||
if len(zfs_dsk_list) == 5:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "2+ disk stripe":
|
||||
if len(zfs_dsk_list) >= 2:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
if self.check_if_small_disk(model[path][1]) is False:
|
||||
zfs_dsk_list.extend([model[path][0] + "-" + model[path][1]])
|
||||
if self.mirror == "single disk":
|
||||
if len(zfs_dsk_list) != 1:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(True)
|
||||
elif self.mirror == "2 disk mirror":
|
||||
if len(zfs_dsk_list) == 2:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "3 disk raidz1":
|
||||
if len(zfs_dsk_list) == 3:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "4 disk raidz2":
|
||||
if len(zfs_dsk_list) == 4:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "5 disk raidz3":
|
||||
if len(zfs_dsk_list) == 5:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "2+ disk stripe":
|
||||
if len(zfs_dsk_list) >= 2:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.check_cell.set_sensitive(False)
|
||||
self.small_disk_warning()
|
||||
|
||||
print(zfs_dsk_list)
|
||||
return True
|
||||
|
||||
def small_disk_warning(self):
|
||||
window = Gtk.Window()
|
||||
window.set_title("Warning")
|
||||
window.set_border_width(0)
|
||||
# window.set_size_request(480, 200)
|
||||
window.set_icon_from_file(logo)
|
||||
box1 = Gtk.VBox(False, 0)
|
||||
window.add(box1)
|
||||
box1.show()
|
||||
box2 = Gtk.VBox(False, 10)
|
||||
box2.set_border_width(10)
|
||||
box1.pack_start(box2, True, True, 0)
|
||||
box2.show()
|
||||
warning_text = "Smallest disk need to be SELECTED first!\n"
|
||||
warning_text += "All the disk selected will reset."
|
||||
label = Gtk.Label(warning_text)
|
||||
# Add button
|
||||
box2.pack_start(label, True, True, 0)
|
||||
bbox = Gtk.HButtonBox()
|
||||
bbox.set_border_width(5)
|
||||
bbox.set_spacing(10)
|
||||
button = Gtk.Button(stock=Gtk.STOCK_OK)
|
||||
button.connect("clicked", self.resset_selection, window)
|
||||
bbox.add(button)
|
||||
box2.pack_end(bbox, True, True, 5)
|
||||
window.show_all()
|
||||
|
||||
def resset_selection(self, widget, window):
|
||||
global zfs_dsk_list
|
||||
zfs_dsk_list = []
|
||||
rows = len(self.store)
|
||||
for row in range(0, rows):
|
||||
self.store[row][3] = False
|
||||
row += 1
|
||||
self.check_cell.set_sensitive(True)
|
||||
window.hide()
|
||||
|
||||
def passwdstrength(self, widget):
|
||||
passwd = self.password.get_text()
|
||||
if len(passwd) <= 4:
|
||||
self.strenght_label.set_text("Super Weak")
|
||||
elif len(passwd) <= 8:
|
||||
if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
|
||||
self.strenght_label.set_text("Super Weak")
|
||||
elif lowerandNunber(passwd):
|
||||
self.strenght_label.set_text("Very Weak")
|
||||
elif upperandNunber(passwd):
|
||||
self.strenght_label.set_text("Very Weak")
|
||||
elif lowerUpperCase(passwd):
|
||||
self.strenght_label.set_text("Very Weak")
|
||||
elif lowerUpperNumber(passwd):
|
||||
self.strenght_label.set_text("Fairly Weak")
|
||||
elif allCharacter(passwd):
|
||||
self.strenght_label.set_text("Weak")
|
||||
elif len(passwd) <= 12:
|
||||
if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
|
||||
self.strenght_label.set_text("Very Weak")
|
||||
elif lowerandNunber(passwd):
|
||||
self.strenght_label.set_text("Fairly Weak")
|
||||
elif upperandNunber(passwd):
|
||||
self.strenght_label.set_text("Fairly Weak")
|
||||
elif lowerUpperCase(passwd):
|
||||
self.strenght_label.set_text("Fairly Weak")
|
||||
elif lowerUpperNumber(passwd):
|
||||
self.strenght_label.set_text("Weak")
|
||||
elif allCharacter(passwd):
|
||||
self.strenght_label.set_text("Strong")
|
||||
elif len(passwd) <= 16:
|
||||
if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
|
||||
self.strenght_label.set_text("Fairly Weak")
|
||||
elif lowerandNunber(passwd):
|
||||
self.strenght_label.set_text("Weak")
|
||||
elif upperandNunber(passwd):
|
||||
self.strenght_label.set_text("Weak")
|
||||
elif lowerUpperCase(passwd):
|
||||
self.strenght_label.set_text("Weak")
|
||||
elif lowerUpperNumber(passwd):
|
||||
self.strenght_label.set_text("Strong")
|
||||
elif allCharacter(passwd):
|
||||
self.strenght_label.set_text("Fairly Strong")
|
||||
elif len(passwd) <= 20:
|
||||
if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
|
||||
self.strenght_label.set_text("Weak")
|
||||
elif lowerandNunber(passwd):
|
||||
self.strenght_label.set_text("Strong")
|
||||
elif upperandNunber(passwd):
|
||||
self.strenght_label.set_text("Strong")
|
||||
elif lowerUpperCase(passwd):
|
||||
self.strenght_label.set_text("Strong")
|
||||
elif lowerUpperNumber(passwd):
|
||||
self.strenght_label.set_text("Fairly Strong")
|
||||
elif allCharacter(passwd):
|
||||
self.strenght_label.set_text("Very Strong")
|
||||
elif len(passwd) <= 24:
|
||||
if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
|
||||
self.strenght_label.set_text("Strong")
|
||||
elif lowerandNunber(passwd):
|
||||
self.strenght_label.set_text("Fairly Strong")
|
||||
elif upperandNunber(passwd):
|
||||
self.strenght_label.set_text("Fairly Strong")
|
||||
elif lowerUpperCase(passwd):
|
||||
self.strenght_label.set_text("Fairly Strong")
|
||||
elif lowerUpperNumber(passwd):
|
||||
self.strenght_label.set_text("Very Strong")
|
||||
elif allCharacter(passwd):
|
||||
self.strenght_label.set_text("Super Strong")
|
||||
elif len(passwd) > 24:
|
||||
if lowerCase(passwd) or upperCase(passwd) or passwd.isdigit():
|
||||
self.strenght_label.set_text("Fairly Strong")
|
||||
else:
|
||||
self.strenght_label.set_text("Super Strong")
|
||||
|
||||
def passwdVerification(self, widget):
|
||||
if self.password.get_text() == self.repassword.get_text():
|
||||
self.img.set_from_stock(Gtk.STOCK_YES, 10)
|
||||
if self.mirror == "single disk":
|
||||
if len(zfs_dsk_list) != 1:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.button3.set_sensitive(True)
|
||||
elif self.mirror == "2 disk mirror":
|
||||
if len(zfs_dsk_list) == 2:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "3 disk raidz1":
|
||||
if len(zfs_dsk_list) == 3:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "4 disk raidz2":
|
||||
if len(zfs_dsk_list) == 4:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "5 disk raidz3":
|
||||
if len(zfs_dsk_list) == 5:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
elif self.mirror == "2+ disk stripe":
|
||||
if len(zfs_dsk_list) >= 2:
|
||||
self.button3.set_sensitive(True)
|
||||
else:
|
||||
self.button3.set_sensitive(False)
|
||||
else:
|
||||
self.img.set_from_stock(Gtk.STOCK_NO, 10)
|
||||
self.button3.set_sensitive(False)
|
||||