diff --git a/LICENSE b/LICENSE index 527844e..dd5715a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014, GhostBSD +Copyright (c) 2020, GhostBSD All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/README.md b/README.md index dc2dbe1..d0147a5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ -gbinstall +Install Station === +It is a strip down version of gbi and it is the new installer for GhostBSD. It depend on gbi. -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. +Install Station only edit disk, partition and will install GhostBSD. Users and system setup will be done with at the first boot after installation with Setup Station \ No newline at end of file diff --git a/gbinstall b/install-station similarity index 100% rename from gbinstall rename to install-station diff --git a/setup.py b/setup.py index cc90d86..454f8a7 100755 --- a/setup.py +++ b/setup.py @@ -34,78 +34,6 @@ def datafilelist(installbase, sourcebase): prefix = sys.prefix -lib_gbinstall = [ - 'src/confirm_installation.py', - 'src/boot_manager.py', - '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' -] - - -backend_query = [ - 'src/backend-query/detect-laptop.sh', - 'src/backend-query/detect-nics.sh', - 'src/backend-query/detect-sheme.sh', - 'src/backend-query/detect-vmware.sh', - 'src/backend-query/detect-wifi.sh', - 'src/backend-query/disk-info.sh', - 'src/backend-query/disk-label.sh', - 'src/backend-query/disk-list.sh', - 'src/backend-query/disk-part.sh', - 'src/backend-query/enable-net.sh', - 'src/backend-query/list-components.sh', - 'src/backend-query/list-rsync-backups.sh', - 'src/backend-query/list-tzones.sh', - 'src/backend-query/query-langs.sh', - 'src/backend-query/send-logs.sh', - 'src/backend-query/setup-ssh-keys.sh', - 'src/backend-query/sys-mem.sh', - 'src/backend-query/test-live.sh', - 'src/backend-query/test-netup.sh', - 'src/backend-query/update-part-list.sh', - 'src/backend-query/xkeyboard-layouts.sh', - 'src/backend-query/xkeyboard-models.sh', - 'src/backend-query/xkeyboard-variants.sh' - -] - -# '{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/backend-query', backend_query), - (f'{prefix}/lib/gbinstall/slide-images/ghostbsd', slide_images) -] - # data_files.extend(datafilelist('{prefix}/share/locale'.format(prefix=sys.prefix), 'build/mo')) # cmdclass ={ @@ -114,14 +42,15 @@ data_files = [ # "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'],) +setup( + name="install-station", + version=PROGRAM_VERSION, + description="install-station is a stripdown version of gbi", + license='BSD', + author='Eric Turgeon', + url='https://github/GhostBSD/install-station/', + package_dir={'': '.'}, + install_requires=['setuptools'], + scripts=['install-station'] +) # cmdclass = cmdclass, diff --git a/src/backend-query/detect-laptop.sh b/src/backend-query/detect-laptop.sh deleted file mode 100755 index bf42842..0000000 --- a/src/backend-query/detect-laptop.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -dmesgLine=`dmesg | grep "acpi_acad0"` -if test "${dmesgLine}" = ""; then - echo "laptop: NO" -else - echo "laptop: YES" -fi diff --git a/src/backend-query/detect-nics.sh b/src/backend-query/detect-nics.sh deleted file mode 100755 index ead211d..0000000 --- a/src/backend-query/detect-nics.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/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 diff --git a/src/backend-query/detect-sheme.sh b/src/backend-query/detect-sheme.sh deleted file mode 100644 index 9f98378..0000000 --- a/src/backend-query/detect-sheme.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/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} diff --git a/src/backend-query/detect-vmware.sh b/src/backend-query/detect-vmware.sh deleted file mode 100755 index 74b32db..0000000 --- a/src/backend-query/detect-vmware.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/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 diff --git a/src/backend-query/detect-wifi.sh b/src/backend-query/detect-wifi.sh deleted file mode 100644 index 985ebc6..0000000 --- a/src/backend-query/detect-wifi.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -NIC="$1" -ifconfig ${NIC} | grep -q "802.11" 2>/dev/null -if [ $? -eq 0 ]; then - echo 'yes' -else - echo 'no' -fi diff --git a/src/backend-query/disk-info.sh b/src/backend-query/disk-info.sh deleted file mode 100755 index 464df45..0000000 --- a/src/backend-query/disk-info.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/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" diff --git a/src/backend-query/disk-label.sh b/src/backend-query/disk-label.sh deleted file mode 100644 index 306bf03..0000000 --- a/src/backend-query/disk-label.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/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} diff --git a/src/backend-query/disk-list.sh b/src/backend-query/disk-list.sh deleted file mode 100755 index c9241d6..0000000 --- a/src/backend-query/disk-list.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/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=" " - 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 diff --git a/src/backend-query/disk-part.sh b/src/backend-query/disk-part.sh deleted file mode 100755 index a8cf5d2..0000000 --- a/src/backend-query/disk-part.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/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} diff --git a/src/backend-query/enable-net.sh b/src/backend-query/enable-net.sh deleted file mode 100755 index ca3115d..0000000 --- a/src/backend-query/enable-net.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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 " - 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 diff --git a/src/backend-query/list-components.sh b/src/backend-query/list-components.sh deleted file mode 100755 index 6833dc7..0000000 --- a/src/backend-query/list-components.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/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 - diff --git a/src/backend-query/list-rsync-backups.sh b/src/backend-query/list-rsync-backups.sh deleted file mode 100755 index 6b32fb1..0000000 --- a/src/backend-query/list-rsync-backups.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/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 " - 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 diff --git a/src/backend-query/list-tzones.sh b/src/backend-query/list-tzones.sh deleted file mode 100755 index 3f8d335..0000000 --- a/src/backend-query/list-tzones.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/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 diff --git a/src/backend-query/query-langs.sh b/src/backend-query/query-langs.sh deleted file mode 100755 index 7951ca6..0000000 --- a/src/backend-query/query-langs.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -FOUND="0" - -cat ${PROGDIR}/conf/avail-langs - -exit 0 diff --git a/src/backend-query/send-logs.sh b/src/backend-query/send-logs.sh deleted file mode 100755 index c182b22..0000000 --- a/src/backend-query/send-logs.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/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 diff --git a/src/backend-query/setup-ssh-keys.sh b/src/backend-query/setup-ssh-keys.sh deleted file mode 100755 index 9b09e99..0000000 --- a/src/backend-query/setup-ssh-keys.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/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 " - 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" diff --git a/src/backend-query/sys-mem.sh b/src/backend-query/sys-mem.sh deleted file mode 100755 index f087621..0000000 --- a/src/backend-query/sys-mem.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -MEM=`sysctl hw.realmem | sed "s|hw.realmem: ||g"` -MEM=`expr $MEM / 1024` -MEM=`expr $MEM / 1024` -echo $MEM diff --git a/src/backend-query/test-live.sh b/src/backend-query/test-live.sh deleted file mode 100755 index 67ec7a5..0000000 --- a/src/backend-query/test-live.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/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 - diff --git a/src/backend-query/test-netup.sh b/src/backend-query/test-netup.sh deleted file mode 100755 index 666781d..0000000 --- a/src/backend-query/test-netup.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/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 diff --git a/src/backend-query/update-part-list.sh b/src/backend-query/update-part-list.sh deleted file mode 100755 index ac81e4f..0000000 --- a/src/backend-query/update-part-list.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/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 diff --git a/src/backend-query/xkeyboard-layouts.sh b/src/backend-query/xkeyboard-layouts.sh deleted file mode 100755 index b2b92f3..0000000 --- a/src/backend-query/xkeyboard-layouts.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/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 diff --git a/src/backend-query/xkeyboard-models.sh b/src/backend-query/xkeyboard-models.sh deleted file mode 100755 index 0d72681..0000000 --- a/src/backend-query/xkeyboard-models.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/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 diff --git a/src/backend-query/xkeyboard-variants.sh b/src/backend-query/xkeyboard-variants.sh deleted file mode 100755 index 3bf18d7..0000000 --- a/src/backend-query/xkeyboard-variants.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/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 diff --git a/src/boot_manager.py b/src/boot_manager.py deleted file mode 100644 index b7fc71c..0000000 --- a/src/boot_manager.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/local/bin/python3.6 -# -# Copyright (c) 2019 GhostBSD - -import gi -gi.require_version('Gtk', '3.0') -from gi.repository import Gtk -import os -import os.path -from db_partition import bios_or_uefi - - -# Folder use pr the installer. -tmp = "/tmp/.gbinstall/" -installer = "/usr/local/lib/gbi/" -query = "sh /usr/local/etc/lib/backend-query/" -if not os.path.exists(tmp): - os.makedirs(tmp) - -logo = "/usr/local/lib/gbi/logo.png" -boot_file = '%sboot' % tmp -disk_schem = '%sscheme' % tmp -zfs_config = '%szfs_config' % tmp -ufs_config = tmp + 'ufs_config' - - -class bootManager(): - - 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() - if bios_or_uefi() == "UEFI": - loader = "UEFI" - else: - loader = "BIOS" - if os.path.exists(zfs_config): - # Disk Setup - read = open(zfs_config, 'r') - schem = read.read() - # os.remove(zfs_config) - elif os.path.exists(ufs_config): - # Disk Setup - read = open(ufs_config, 'r') - schem = read.readlines() - else: - # Sheme sheme - read = open(disk_schem, 'r') - schem = read.read() - if 'GPT' in schem: - scheme = 'GPT' - else: - scheme = 'MBR' - label = Gtk.Label("Boot Option", name="Header") - label.set_property("height-request", 40) - box2.pack_start(label, False, False, 0) - hbox = Gtk.HBox() - hbox.show() - box2.pack_start(hbox, True, True, 0) - bbox1 = Gtk.VBox() - bbox1.show() - self.refind = Gtk.RadioButton.new_with_label_from_widget(None, "Setup rEFInd boot manager") - bbox1.pack_start(self.refind, False, True, 10) - self.refind.connect("toggled", self.boot_manager, "refind") - self.refind.show() - if scheme == 'GPT' and loader == "UEFI": - self.refind.set_sensitive(True) - else: - self.refind.set_sensitive(False) - self.bsd = Gtk.RadioButton.new_with_label_from_widget(self.refind, "Setup FreeBSD boot manager") - bbox1.pack_start(self.bsd, False, True, 10) - self.bsd.connect("toggled", self.boot_manager, "bsd") - self.bsd.show() - if scheme == 'MBR': - self.bsd.set_sensitive(True) - else: - self.bsd.set_sensitive(False) - self.none = Gtk.RadioButton.new_with_label_from_widget(self.bsd, f"FreeBSD {loader} loader only") - 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 diff --git a/src/confirm_installation.py b/src/confirm_installation.py deleted file mode 100644 index 50dcd0e..0000000 --- a/src/confirm_installation.py +++ /dev/null @@ -1,120 +0,0 @@ -#!/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, Gdk -import os -import os.path -import sys -from create_cfg import gbsd_cfg - -# Folder use for the installer. -tmp = "/tmp/.gbinstall/" -pcinstallcfg = f'{tmp}pcinstall.cfg' -installer = "/usr/local/lib/gbinstall/" -logo = f"{installer}logo.png" -if not os.path.exists(tmp): - os.makedirs(tmp) - -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 Summary: - - def __init__(self, button3): - gbsd_cfg() - cfg_file = open(pcinstallcfg, 'r') - cfg_text = cfg_file.read() - cfg_file.close() - button3.set_sensitive(True) - # Add a Default vertical box - self.vbox1 = Gtk.VBox(False, 0) - self.vbox1.show() - # Add a second vertical box - label = Gtk.Label("Installation Summary", name="Header") - label.set_property("height-request", 40) - self.vbox1.pack_start(label, False, False, 0) - 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 - scrolledwindow = Gtk.ScrolledWindow() - scrolledwindow.set_hexpand(True) - scrolledwindow.set_vexpand(True) - scrolledwindow.show() - grid.attach(scrolledwindow, 0, 1, 3, 1) - - self.textview = Gtk.TextView() - self.textbuffer = self.textview.get_buffer() - self.textbuffer.set_text(cfg_text) - scrolledwindow.add(self.textview) - - # 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 diff --git a/src/create_cfg.py b/src/create_cfg.py deleted file mode 100644 index 096cbf8..0000000 --- a/src/create_cfg.py +++ /dev/null @@ -1,130 +0,0 @@ -#!/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') - 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() - if boot == 'refind': - f.writelines('bootManager=none\n') - f.writelines('efiLoader=%s\n' % boot) - else: - f.writelines('bootManager=%s\n' % boot) - f.writelines('efiLoader=none\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) - if boot == 'refind': - f.writelines('bootManager=none\n') - f.writelines('efiLoader=%s\n' % boot) - else: - f.writelines('bootManager=%s\n' % boot) - f.writelines('efiLoader=none\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() - if boot == 'refind': - f.writelines('bootManager=none\n') - f.writelines('efiLoader=%s\n' % boot) - else: - f.writelines('bootManager=%s\n' % boot) - f.writelines('efiLoader=none\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) - f.writelines('runExtCommand=cat /etc/rc.conf | grep kld_list >> $FSMNT/etc/rc.conf\n') - if os.path.exists("/etc/X11/xorg.conf"): - f.writelines('runExtCommand=cp /etc/X11/xorg.conf $FSMNT/etc/X11/xorg.conf\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}') - f.close() diff --git a/src/db_partition.py b/src/db_partition.py deleted file mode 100644 index ad68ee7..0000000 --- a/src/db_partition.py +++ /dev/null @@ -1,1019 +0,0 @@ -#!/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. -""" - -import os -import re -from subprocess import Popen, PIPE, STDOUT, call -import pickle -from time import sleep - -tmp = "/tmp/.gbinstall/" -if not os.path.exists(tmp): - os.makedirs(tmp) -installer = "/usr/local/lib/gbinstall/" -sysinstall = "/usr/local/sbin/pc-sysinstall" -partitiondb = "%spartitiondb/" % tmp -query = "sh /usr/local/lib/gbinstall/backend-query/" -query_disk = '%sdisk-list.sh' % query -detect_sheme = '%sdetect-sheme.sh' % query -diskdb = "%sdisk" % partitiondb -query_partition = '%sdisk-part.sh' % query -query_label = '%sdisk-label.sh' % query -disk_info = '%sdisk-info.sh' % query -nl = "\n" -memory = 'sysctl hw.physmem' -disk_file = '%sdisk' % tmp -dslice = '%sslice' % tmp -Part_label = '%spartlabel' % tmp -part_schem = '%sscheme' % tmp -boot_file = '%sboot' % tmp - - -def disk_query(): - df = open(diskdb, 'rb') - dl = pickle.load(df) - return dl - - -def zfs_disk_query(): - disk_output = Popen(sysinstall + " disk-list", shell=True, stdin=PIPE, - stdout=PIPE, universal_newlines=True, close_fds=True) - return disk_output.stdout.readlines() - - -def zfs_disk_size_query(disk): - disk_info_output = Popen(sysinstall + " disk-info " + disk, shell=True, - stdin=PIPE, stdout=PIPE, universal_newlines=True, - close_fds=True) - return disk_info_output.stdout.readlines()[3].partition('=')[2] - - -def how_partition(path): - disk = disk_query()[path[0]][0] - if os.path.exists(partitiondb + disk): - part = partition_query(disk) - return len(part) - else: - return 0 - - -def first_is_free(path): - disk = disk_query()[path[0]][0] - if os.path.exists(partitiondb + disk): - part = partition_query(disk) - return part[0][0] - else: - return None - - -def partition_query(disk): - plist = open(partitiondb + disk, 'rb') - pl = pickle.load(plist) - return pl - - -def label_query(pslice): - llist = open(partitiondb + pslice, 'rb') - ll = pickle.load(llist) - return ll - - -def scheme_query(path): - disk = disk_query()[path[0]] - return disk[-1] - - -def find_scheme(disk): - cmd = "%s %s" % (detect_sheme, disk) - shm_out = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, - universal_newlines=True, close_fds=True) - scheme = shm_out.stdout.readlines()[0].rstrip() - return scheme - - -def int_size(size): - size = int(size) - return size - - -def rpartslice(part): - item = part - p = set("p") - s = set("s") - if p & set(item): - drive = item.partition('p')[0] - elif s & set(item): - drive = item.partition('s')[0] - return drive - - -def sliceNum(part): - item = part - p = set("p") - s = set("s") - if p & set(item): - num = int(item.partition('p')[2]) - elif s & set(item): - num = int(item.partition('s')[2]) - return num - - -def slicePartition(part): - item = part - p = set("p") - s = set("s") - if p & set(item): - return 'p' - elif s & set(item): - return 's' - - -class diskSchemeChanger(): - - def __init__(self, schm, path, disk, size): - dlist = disk_query() - dselected = dlist[path[0]] - if schm is None: - dselected[-1] = 'GPT' - else: - dselected[-1] = schm - dlist[path[0]] = dselected - disk = dselected[0] - df = open(diskdb, 'wb') - pickle.dump(dlist, df) - df.close() - dsl = [] - mdsl = [] - if os.path.exists(tmp + 'destroy'): - df = open(tmp + 'destroy', 'rb') - mdsl = pickle.load(df) - dsl.extend(([disk, schm])) - mdsl.append(dsl) - cf = open(tmp + 'destroy', 'wb') - pickle.dump(mdsl, cf) - cf.close() - if not os.path.exists(partitiondb + disk): - plist = [] - mplist = [] - psf = open(partitiondb + disk, 'wb') - plist.extend((['freespace', size, '', ''])) - mplist.append(plist) - pickle.dump(mplist, psf) - psf.close() - - -class partition_repos(): - - def disk_list(self): - disk_output = Popen(query_disk, shell=True, stdin=PIPE, stdout=PIPE, - universal_newlines=True, close_fds=True) - dlist = [] - for disk in disk_output.stdout: - dlist.append(disk.split()) - return dlist - - def disk_size(self, disk): - cmd = "%s %s" % (disk_info, disk) - ds = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, - universal_newlines=True, stderr=STDOUT, close_fds=True) - diskSize = ds.stdout.readlines()[0].rstrip() - return diskSize - - def find_Scheme(self, disk): - cmd = "%s %s" % (detect_sheme, disk) - shm_out = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, - universal_newlines=True, stderr=STDOUT, close_fds=True) - scheme = shm_out.stdout.readlines()[0].rstrip() - return scheme - - def mbr_partition_slice_list(self, disk): - partition_outpput = Popen('%s %s' % (query_partition, disk), - shell=True, stdin=PIPE, stdout=PIPE, - universal_newlines=True, close_fds=True) - plist = [] - mplist = [] - dpsf = open(partitiondb + disk, 'wb') - for line in partition_outpput.stdout: - info = line.split() - plist.extend((info[0], info[1].partition('M')[0], '', info[2])) - mplist.append(plist) - plist = [] - self.mbr_partition_list(info[0]) - pickle.dump(mplist, dpsf) - dpsf.close() - - def mbr_partition_list(self, pslice): - slice_outpput = Popen('%s %s' % (query_label, pslice), shell=True, - stdin=PIPE, stdout=PIPE, - universal_newlines=True, close_fds=True) - alph = ord('a') - if pslice == 'freespace': - pass - else: - llist = [] - mllist = [] - plf = open(partitiondb + pslice, 'wb') - for line in slice_outpput.stdout: - info = line.split() - letter = chr(alph) - alph = alph + 1 - if info[0] == 'freespace': - llist.extend(([info[0], info[1].partition('M')[0], '', '']) - ) - else: - llist.extend(( - [pslice + letter, info[0].partition('M')[0], - '', info[1]])) - mllist.append(llist) - llist = [] - pickle.dump(mllist, plf) - plf.close() - - def gpt_partition_list(self, disk): - partition_outpput = Popen('%s %s' % (query_partition, disk), - shell=True, stdin=PIPE, stdout=PIPE, - universal_newlines=True, close_fds=True) - plist = [] - mplist = [] - psf = open(partitiondb + disk, 'wb') - for line in partition_outpput.stdout: - info = line.split() - plist.extend((info[0], info[1].partition('M')[0], '', info[2])) - mplist.append(plist) - plist = [] - pickle.dump(mplist, psf) - psf.close() - - def __init__(self): - if not os.path.exists(partitiondb): - os.makedirs(partitiondb) - df = open(diskdb, 'wb') - dlist = [] - mdlist = [] - for disk in self.disk_list(): - if self.find_Scheme(disk[0]) == "GPT": - dlist.extend(([disk[0], self.disk_size(disk[0]), '', 'GPT'])) - self.gpt_partition_list(disk[0]) - mdlist.append(dlist) - elif self.find_Scheme(disk[0]) == "MBR": - dlist.extend(([disk[0], self.disk_size(disk[0]), '', 'MBR'])) - self.mbr_partition_slice_list(disk[0]) - mdlist.append(dlist) - else: - dlist.extend(([disk[0], self.disk_size(disk[0]), '', None])) - mdlist.append(dlist) - dlist = [] - pickle.dump(mdlist, df) - df.close() - - -class Delete_partition(): - - def find_if_lable(seff, part): - last = part[-1] - if re.search('[a-z]', last): - return True - - def delete_label(self, part, spart, path): - llist = open(partitiondb + spart, 'rb') - ll = pickle.load(llist) - last_num = len(ll) - 1 - lnum = path[2] - if last_num == lnum: - free = int_size(ll[last_num][1]) - if lnum != 0 and ll[lnum - 1][0] == 'freespace': - free = free + int_size(ll[lnum - 1][1]) - ll[lnum] = ['freespace', free, '', ''] - ll.remove(ll[lnum - 1]) - else: - ll[lnum] = ['freespace', free, '', ''] - elif lnum == 0: - free = int_size(ll[lnum][1]) - if ll[lnum + 1][0] == 'freespace': - free = free + int_size(ll[lnum + 1][1]) - ll.remove(ll[lnum + 1]) - ll[lnum] = ['freespace', free, '', ''] - else: - free = int_size(ll[lnum][1]) - if ll[lnum + 1][0] == 'freespace': - free = free + int_size(ll[lnum + 1][1]) - ll.remove(ll[lnum + 1]) - if lnum != 0 and ll[lnum - 1][0] == 'freespace': - free = free + int_size(ll[lnum - 1][1]) - ll[lnum] = ['freespace', free, '', ''] - ll.remove(ll[lnum - 1]) - else: - ll[lnum] = ['freespace', free, '', ''] - savepl = open(partitiondb + spart, 'wb') - pickle.dump(ll, savepl) - savepl.close() - - llist = open(partitiondb + spart, 'rb') - lablelist = pickle.load(llist) - pfile = open(Part_label, 'w') - for partlist in lablelist: - if partlist[2] != '': - pfile.writelines('%s %s %s\n' % (partlist[3], partlist[1], - partlist[2])) - pfile.close() - - def __init__(self, part, path): - if part == "freespace": - pass - elif self.find_if_lable(part) is True: - spart = part[:-1] - self.delete_label(part, spart, path) - else: - drive = rpartslice(part) - self.delete_slice(drive, part, path) - - def delete_slice(self, drive, part, path): - slist = open(partitiondb + drive, 'rb') - sl = pickle.load(slist) - last_num = len(sl) - 1 - snum = path[1] - if os.path.exists(dslice): - sfile = open(dslice, 'r') - slf = sfile.readlines()[0].rstrip() - if slf == 'all': - ptnum = snum - 1 - else: - slnum = int(re.sub("[^0-9]", "", slf)) - ptnum = snum - slnum - if last_num == snum: - free = int_size(sl[last_num][1]) - if snum != 0 and sl[snum - 1][0] == 'freespace': - free = free + int_size(sl[snum - 1][1]) - sl[snum] = ['freespace', free, '', ''] - sl.remove(sl[snum - 1]) - else: - sl[snum] = ['freespace', free, '', ''] - elif snum == 0: - free = int_size(sl[snum][1]) - if sl[snum + 1][0] == 'freespace': - free = free + int_size(sl[snum + 1][1]) - sl.remove(sl[snum + 1]) - sl[snum] = ['freespace', free, '', ''] - else: - sl[snum] = ['freespace', free, '', ''] - else: - free = int_size(sl[snum][1]) - slice_after = sl[snum + 1][0] - slice_before = sl[snum - 1][0] - size_after = sl[snum + 1] - size_before = sl[snum - 1] - if slice_after == 'freespace' and slice_before == 'freespace': - free = free + int_size(size_after) + int_size(size_before) - sl[snum] = ['freespace', free, '', ''] - sl.remove(sl[snum + 1]) - sl.remove(sl[snum - 1]) - elif slice_after == 'freespace': - free = free + int_size(sl[snum + 1][1]) - sl[snum] = ['freespace', free, '', ''] - sl.remove(sl[snum + 1]) - elif snum != 0 and sl[snum - 1][0] == 'freespace': - free = free + int_size(sl[snum - 1][1]) - sl[snum] = ['freespace', free, '', ''] - sl.remove(sl[snum - 1]) - else: - sl[snum] = ['freespace', free, '', ''] - # Making delete file - dl = [] - mdl = [] - data = True - # if delete exist check if slice is in delete. - if os.path.exists(tmp + 'delete'): - df = open(tmp + 'delete', 'rb') - mdl = pickle.load(df) - for line in mdl: - if part in line: - data = False - break - if data is True: - dl.extend(([part, free])) - mdl.append(dl) - cf = open(tmp + 'delete', 'wb') - pickle.dump(mdl, cf) - cf.close() - if os.path.exists(partitiondb + part): - os.remove(partitiondb + part) - saveps = open(partitiondb + drive, 'wb') - pickle.dump(sl, saveps) - saveps.close() - if "p" in part: - pfile = open(Part_label, 'w') - for partlist in partition_query(drive): - if partlist[2] != '': - partition = f'{partlist[3]} {partlist[1]} {partlist[2]}\n' - pfile.writelines(partition) - pfile.close() - - -class autoDiskPartition(): - - def delete_mbr_partition(self, disk): - plist = partition_query(disk) - for part in plist: - if part[0] == 'freespace': - pass - else: - os.remove(partitiondb + part[0]) - - def create_mbr_partiton(self, disk, size): - file_disk = open(disk_file, 'w') - file_disk.writelines('%s\n' % disk) - file_disk.close() - sfile = open(part_schem, 'w') - sfile.writelines('partscheme=MBR') - sfile.close() - plist = [] - mplist = [] - dpsf = open(partitiondb + disk, 'wb') - plist.extend((disk + "s1", size, '', 'freebsd')) - mplist.append(plist) - pickle.dump(mplist, dpsf) - dpsf.close() - number = int(size.partition('M')[0]) - slice_file = open(dslice, 'w') - slice_file.writelines('all\n') - slice_file.writelines('%s\n' % number) - slice_file.close() - ram = Popen(memory, shell=True, stdin=PIPE, stdout=PIPE, - universal_newlines=True, close_fds=True) - mem = ram.stdout.read() - swap = int(int(mem.partition(':')[2].strip()) / (1024 * 1024)) - rootNum = int(number - swap) - llist = [] - mllist = [] - plf = open(partitiondb + disk + 's1', 'wb') - llist.extend(([disk + 's1a', rootNum, '/', 'UFS+SUJ'])) - mllist.append(llist) - llist = [] - llist.extend(([disk + 's1b', swap, 'none', 'SWAP'])) - mllist.append(llist) - pickle.dump(mllist, plf) - plf.close() - pfile = open(Part_label, 'w') - pfile.writelines('UFS+SUJ %s /\n' % rootNum) - pfile.writelines('SWAP 0 none\n') - pfile.close() - - def __init__(self, disk, size, schm): - if schm == 'GPT': - self.create_gpt_partiton(disk, size) - elif schm == 'MBR': - if os.path.exists(partitiondb + disk): - self.delete_mbr_partition(disk) - self.create_mbr_partiton(disk, size) - - def create_gpt_partiton(self, disk, size): - file_disk = open(disk_file, 'w') - file_disk.writelines('%s\n' % disk) - file_disk.close() - sfile = open(part_schem, 'w') - sfile.writelines('partscheme=GPT') - sfile.close() - number = int(size.partition('M')[0]) - slice_file = open(dslice, 'w') - slice_file.writelines('all\n') - slice_file.writelines('%s\n' % number) - slice_file.close() - ram = Popen(memory, shell=True, stdin=PIPE, stdout=PIPE, - universal_newlines=True, close_fds=True) - mem = ram.stdout.read() - swap = int(int(mem.partition(':')[2].strip()) / (1024 * 1024)) - if bios_or_uefi() == "UEFI": - bnum = 100 - else: - bnum = 1 - rootNum = int(number - swap) - rnum = int(rootNum - bnum) - plist = [] - mplist = [] - plf = open(partitiondb + disk, 'wb') - if bios_or_uefi() == "UEFI": - plist.extend(([disk + 'p1', bnum, 'none', 'UEFI'])) - else: - plist.extend(([disk + 'p1', bnum, 'none', 'BOOT'])) - mplist.append(plist) - plist = [] - plist.extend(([disk + 'p2', rnum, '/', 'UFS+SUJ'])) - mplist.append(plist) - plist = [] - plist.extend(([disk + 'p3', swap, 'none', 'SWAP'])) - mplist.append(plist) - pickle.dump(mplist, plf) - plf.close() - pfile = open(Part_label, 'w') - if bios_or_uefi() == "UEFI": - pfile.writelines('UEFI %s none\n' % bnum) - else: - pfile.writelines('BOOT %s none\n' % bnum) - pfile.writelines('UFS+SUJ %s /\n' % rnum) - pfile.writelines('SWAP 0 none\n') - pfile.close() - - -class autoFreeSpace(): - - def create_mbr_partiton(self, disk, size, sl, path): - file_disk = open(disk_file, 'w') - file_disk.writelines('%s\n' % disk) - file_disk.close() - sfile = open(part_schem, 'w') - sfile.writelines('partscheme=MBR') - sfile.close() - plist = [] - mplist = partition_query(disk) - dpsf = open(partitiondb + disk, 'wb') - plist.extend((disk + "s%s" % sl, size, '', 'freebsd')) - mplist[path] = plist - pickle.dump(mplist, dpsf) - dpsf.close() - number = int(size) - slice_file = open(dslice, 'w') - slice_file.writelines('s%s\n' % sl) - slice_file.writelines('%s\n' % number) - slice_file.close() - ram = Popen(memory, shell=True, stdin=PIPE, stdout=PIPE, - universal_newlines=True, close_fds=True) - mem = ram.stdout.read() - swap = int(int(mem.partition(':')[2].strip()) / (1024 * 1024)) - rootNum = int(number - swap) - llist = [] - mllist = [] - plf = open(partitiondb + disk + 's%s' % sl, 'wb') - llist.extend(([disk + 's%sa' % sl, rootNum, '/', 'UFS+SUJ'])) - mllist.append(llist) - llist = [] - llist.extend(([disk + 's%sb' % sl, swap, 'none', 'SWAP'])) - mllist.append(llist) - pickle.dump(mllist, plf) - plf.close() - pfile = open(Part_label, 'w') - pfile.writelines('UFS+SUJ %s /\n' % rootNum) - pfile.writelines('SWAP %s none\n' % int(swap - 1)) - pfile.close() - pl = [] - mpl = [] - if os.path.exists(tmp + 'create'): - pf = open(tmp + 'create', 'rb') - mpl = pickle.load(pf) - pl.extend(([disk + "s%s" % sl, size])) - mpl.append(pl) - cf = open(tmp + 'create', 'wb') - pickle.dump(mpl, cf) - cf.close() - - def __init__(self, path, size): - disk = disk_query()[path[0]][0] - schm = disk_query()[path[0]][3] - sl = path[1] + 1 - lv = path[1] - if schm == "GPT": - self.create_gpt_partiton(disk, size, sl, lv) - elif schm == "MBR": - self.create_mbr_partiton(disk, size, sl, lv) - - def create_gpt_partiton(self, disk, size, sl, path): - file_disk = open(disk_file, 'w') - file_disk.writelines('%s\n' % disk) - file_disk.close() - sfile = open(part_schem, 'w') - sfile.writelines('partscheme=GPT') - sfile.close() - number = int(size.partition('M')[0]) - number = number - 512 - ram = Popen(memory, shell=True, stdin=PIPE, stdout=PIPE, - universal_newlines=True, close_fds=True) - mem = ram.stdout.read() - swap = int(int(mem.partition(':')[2].strip()) / (1024 * 1024)) - rootNum = int(number - swap) - if bios_or_uefi() == "UEFI": - bs = 100 - else: - bs = 1 - rootNum = int(rootNum - bs) - plist = [] - mplist = partition_query(disk) - plf = open(partitiondb + disk, 'wb') - done = False - if bios_or_uefi() == "UEFI" and efi_exist(disk) is False: - plist.extend(([disk + 'p%s' % sl, bs, 'none', 'UEFI'])) - rsl = int(sl + 1) - swsl = int(rsl + 1) - elif bios_or_uefi() == "UEFI" and efi_exist(disk) is True: - rsl = int(sl) - swsl = int(rsl + 1) - else: - plist.extend(([disk + 'p%s' % sl, bs, 'none', 'BOOT'])) - rsl = int(sl + 1) - swsl = (rsl + 1) - if len(plist) != 0: - done = True - mplist[path] = plist - plist = [] - plist.extend(([disk + 'p%s' % rsl, rootNum, '/', 'UFS+SUJ'])) - if done is False: - mplist[path] = plist - else: - mplist.append(plist) - plist = [] - plist.extend(([disk + 'p%s' % swsl, swap, 'none', 'SWAP'])) - mplist.append(plist) - pickle.dump(mplist, plf) - plf.close() - slice_file = open(dslice, 'w') - slice_file.writelines(f'p{rsl}') - slice_file.close() - pfile = open(Part_label, 'w') - if bios_or_uefi() == "UEFI" and efi_exist(disk) is False: - pfile.writelines('UEFI %s none\n' % bs) - else: - pfile.writelines('BOOT %s none\n' % bs) - pfile.writelines('UFS+SUJ %s /\n' % rootNum) - pfile.writelines('SWAP %s none\n' % int(swap - 1)) - pfile.close() - pl = [] - mpl = [] - if bios_or_uefi() == "UEFI" and efi_exist(disk) is True: - pass - else: - if not os.path.exists(tmp + 'create'): - pl.extend(([disk + "p%s" % sl, size])) - mpl.append(pl) - cf = open(tmp + 'create', 'wb') - pickle.dump(mpl, cf) - cf.close() - - -class createLabel(): - - def __init__(self, path, lnumb, cnumb, label, fs, data): - disk = disk_query()[path[0]][0] - if not os.path.exists(disk_file): - file_disk = open(disk_file, 'w') - file_disk.writelines('%s\n' % disk) - file_disk.close() - sl = path[1] + 1 - lv = path[2] - sfile = open(part_schem, 'w') - sfile.writelines('partscheme=MBR') - sfile.close() - slice_file = open(dslice, 'w') - slice_file.writelines('s%s\n' % sl) - slice_file.close() - alph = ord('a') - alph += lv - letter = chr(alph) - llist = [] - mllist = label_query(disk + 's%s' % sl) - plf = open(partitiondb + disk + 's%s' % sl, 'wb') - if lnumb == 0: - cnumb -= 1 - llist.extend(([disk + 's%s' % sl + letter, cnumb, label, fs])) - mllist[lv] = llist - llist = [] - if lnumb > 0: - llist.extend((['freespace', lnumb, '', ''])) - mllist.append(llist) - pickle.dump(mllist, plf) - plf.close() - llist = open(partitiondb + disk + 's%s' % sl, 'rb') - labellist = pickle.load(llist) - pfile = open(Part_label, 'w') - for partlist in labellist: - if partlist[2] != '': - pfile.writelines('%s %s %s\n' % (partlist[3], partlist[1], - partlist[2])) - pfile.close() - - -class modifyLabel(): - - def __init__(self, path, lnumb, cnumb, label, fs, data): - disk = disk_query()[path[0]][0] - if not os.path.exists(disk_file): - file_disk = open(disk_file, 'w') - file_disk.writelines('%s\n' % disk) - file_disk.close() - sl = path[1] + 1 - lv = path[2] - sfile = open(part_schem, 'w') - sfile.writelines('partscheme=MBR') - sfile.close() - slice_file = open(dslice, 'w') - slice_file.writelines('s%s\n' % sl) - slice_file.close() - alph = ord('a') - alph += lv - letter = chr(alph) - llist = [] - mllist = label_query(disk + 's%s' % sl) - plf = open(partitiondb + disk + 's%s' % sl, 'wb') - if lnumb == 0: - cnumb -= 1 - llist.extend(([disk + 's%s' % sl + letter, cnumb, label, fs])) - mllist[lv] = llist - llist = [] - if lnumb > 0: - llist.extend((['freespace', lnumb, '', ''])) - mllist.append(llist) - pickle.dump(mllist, plf) - plf.close() - llist = open(partitiondb + disk + 's%s' % sl, 'rb') - labellist = pickle.load(llist) - pfile = open(Part_label, 'w') - for partlist in labellist: - if partlist[2] != '': - pfile.writelines('%s %s %s\n' % (partlist[3], partlist[1], - partlist[2])) - pfile.close() - - -class createSlice(): - - def __init__(self, size, rs, path): - disk = disk_query()[path[0]][0] - file_disk = open(disk_file, 'w') - file_disk.writelines('%s\n' % disk) - file_disk.close() - if len(path) == 1: - sl = 1 - else: - sl = path[1] + 1 - sfile = open(part_schem, 'w') - sfile.writelines('partscheme=MBR') - sfile.close() - slice_file = open(dslice, 'w') - slice_file.writelines('s%s\n' % sl) - slice_file.close() - plist = partition_query(disk) - pslice = '%ss%s' % (disk, path[1] + 1) - if rs == 0: - size -= 1 - plist[path[1]] = [pslice, size, '', 'freebsd'] - if rs > 0: - plist.append(['freespace', rs, '', '']) - psf = open(partitiondb + disk, 'wb') - pickle.dump(plist, psf) - psf.close() - llist = [] - mllist = [] - llist.extend((['freespace', size, '', ''])) - mllist.append(llist) - plf = open(partitiondb + pslice, 'wb') - pickle.dump(mllist, plf) - plf.close() - slice_file = open(dslice, 'w') - slice_file.writelines('s%s\n' % pslice) - slice_file.close() - pl = [] - mpl = [] - if os.path.exists(tmp + 'create'): - pf = open(tmp + 'create', 'rb') - mpl = pickle.load(pf) - pl.extend(([pslice, size])) - mpl.append(pl) - cf = open(tmp + 'create', 'wb') - pickle.dump(mpl, cf) - cf.close() - - -class createPartition(): - - def __init__(self, path, lnumb, inumb, cnumb, label, fs, create): - disk = disk_query()[path[0]][0] - if not os.path.exists(disk_file): - file_disk = open(disk_file, 'w') - file_disk.writelines('%s\n' % disk) - file_disk.close() - if len(path) == 1: - pl = 1 - lv = 0 - else: - pl = path[1] + 1 - lv = path[1] - if not os.path.exists(part_schem): - sfile = open(part_schem, 'w') - sfile.writelines('partscheme=GPT') - sfile.close() - if label == '/': - slice_file = open(dslice, 'w') - slice_file.writelines('p%s\n' % pl) - # slice_file.writelines('%s\n' % number) - slice_file.close() - plist = [] - pslice = '%sp%s' % (disk, pl) - mplist = partition_query(disk) - if lnumb == 0 and cnumb > 1: - cnumb -= 1 - pf = open(partitiondb + disk, 'wb') - plist.extend(([disk + 'p%s' % pl, cnumb, label, fs])) - mplist[lv] = plist - plist = [] - if lnumb > 0: - plist.extend((['freespace', lnumb, '', ''])) - mplist.append(plist) - pickle.dump(mplist, pf) - pf.close() - pfile = open(Part_label, 'w') - for partlist in partition_query(disk): - if partlist[2] != '': - pfile.writelines('%s %s %s\n' % (partlist[3], partlist[1], - partlist[2])) - pfile.close() - if create is True: - plst = [] - mplst = [] - if not os.path.exists(tmp + 'create'): - plst.extend(([pslice, cnumb])) - mplst.append(plst) - cf = open(tmp + 'create', 'wb') - pickle.dump(mplst, cf) - cf.close() - - -class modifyPartition(): - - def __init__(self, path, lnumb, inumb, cnumb, label, fs, data): - disk = disk_query()[path[0]][0] - if not os.path.exists(disk_file): - file_disk = open(disk_file, 'w') - file_disk.writelines('%s\n' % disk) - file_disk.close() - if len(path) == 1: - pl = 1 - lv = 0 - else: - pl = path[1] + 1 - lv = path[1] - if not os.path.exists(part_schem): - sfile = open(part_schem, 'w') - sfile.writelines('partscheme=GPT') - sfile.close() - if label == '/': - slice_file = open(dslice, 'w') - slice_file.writelines('p%s\n' % pl) - slice_file.close() - plist = [] - pslice = '%sp%s' % (disk, pl) - mplist = partition_query(disk) - if lnumb == 0: - cnumb -= 1 - pf = open(partitiondb + disk, 'wb') - plist.extend(([disk + 'p%s' % pl, cnumb, label, fs])) - mplist[lv] = plist - plist = [] - if lnumb > 0: - plist.extend((['freespace', lnumb, '', ''])) - mplist.append(plist) - pickle.dump(mplist, pf) - pf.close() - pfile = open(Part_label, 'w') - for partlist in partition_query(disk): - if partlist[2] != '': - pfile.writelines('%s %s %s\n' % (partlist[3], partlist[1], - partlist[2])) - pfile.close() - if data is True: - plst = [] - mplst = [] - if not os.path.exists(tmp + 'create'): - plst.extend(([pslice, cnumb])) - mplst.append(plst) - cf = open(tmp + 'create', 'wb') - pickle.dump(mplst, cf) - cf.close() - - -class rDeleteParttion(): - def __init__(self): - if os.path.exists(tmp + 'delete'): - df = open(tmp + 'delete', 'rb') - dl = pickle.load(df) - for line in dl: - part = line[0] - num = sliceNum(part) - hd = rpartslice(part) - call('gpart delete -i %s %s' % (num, hd), shell=True) - sleep(2) - - -class destroyParttion(): - def __init__(self): - if os.path.exists(tmp + 'destroy'): - dsf = open(tmp + 'destroy', 'rb') - ds = pickle.load(dsf) - for line in ds: - drive = line[0] - scheme = line[1] - # Destroy the disk geom - gpart_destroy = f"gpart destroy -F {drive}" - zpool_clear = f"zpool labelclear -f ${drive}" - call(gpart_destroy, shell=True) - sleep(1) - call(zpool_clear, shell=True) - sleep(1) - # Make double-sure - create_gpt = f"gpart create -s gpt {drive}" - call(create_gpt, shell=True) - sleep(1) - call(gpart_destroy, shell=True) - sleep(1) - clear_drive = f"dd if=/dev/zero of={drive} bs=1m count=1" - call(clear_drive, shell=True) - sleep(1) - call(f'gpart create -s {scheme} {drive}', shell=True) - sleep(1) - - -def bios_or_uefi(): - cmd = "kenv grub.platform" - output = Popen(cmd, shell=True, stdout=PIPE, - universal_newlines=True, close_fds=True) - kenvoutput = output.stdout.readlines() - if len(kenvoutput) == 0: - cmd = "sysctl -n machdep.bootmethod" - output1 = Popen(cmd, shell=True, stdout=PIPE, - universal_newlines=True, close_fds=True) - return output1.stdout.readlines()[0].rstrip() - elif kenvoutput == "efi": - return "UEFI" - else: - return "BIOS" - - -def efi_exist(disk): - cmd = f"gpart show {disk} | grep efi" - process = Popen(cmd, shell=True, stdout=PIPE, - universal_newlines=True, close_fds=True) - output = process.stdout.readlines() - if len(output) == 0: - return False - else: - return True - - -class makingParttion(): - - def __init__(self): - if os.path.exists(tmp + 'create'): - pf = open(tmp + 'create', 'rb') - pl = pickle.load(pf) - read = open(boot_file, 'r') - boot = read.readlines()[0].strip() - size = 0 - for line in pl: - part = line[0] - drive = rpartslice(part) - sl = sliceNum(part) - if slicePartition(part) == 'p': - if bios_or_uefi() == 'UEFI': - cmd = 'gpart add -s 100M -t efi -i %s %s' % (sl, drive) - sleep(2) - cmd2 = 'newfs_msdos -F 16 %sp%s' % (drive, sl) - call(cmd, shell=True) - call(cmd2, shell=True) - else: - if boot == "grub": - cmd = 'gpart add -a 4k -s 1M -t bios-boot -i' \ - f' {sl} {drive}' - else: - cmd = 'gpart add -a 4k -s 512 -t freebsd-boot -i' \ - f' {sl} {drive}' - call(cmd, shell=True) - elif slicePartition(part) == 's': - size = int(line[1]) - block = int(size * 2048) - cmd = f'gpart add -a 4k -s {block} -t freebsd -i {sl} ' \ - f'{drive}' - call(cmd, shell=True) - sleep(2) diff --git a/src/end.py b/src/end.py deleted file mode 100644 index 82f1c97..0000000 --- a/src/end.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/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() diff --git a/src/error.py b/src/error.py deleted file mode 100644 index 7d19e95..0000000 --- a/src/error.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/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('Installation has failed!') - label = gtk.Label(lyrics) - label.set_use_markup(True) - - label.set_markup("Please report the issue to GhostBSD issue system,\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() diff --git a/src/gbiWindow.py b/src/gbiWindow.py deleted file mode 100644 index 028969e..0000000 --- a/src/gbiWindow.py +++ /dev/null @@ -1,252 +0,0 @@ -#!/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 confirm_installation import Summary -from use_zfs import ZFS -from db_partition import partition_repos -from boot_manager import bootManager -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: - 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, 1) - 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, 1) - 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, 1) - self.window.show_all() - self.notebook.next_page() - self.button3.set_sensitive(False) - elif page == 1: - self.partition.save_selection() - Mbox = Gtk.VBox(False, 0) - Mbox.show() - self.bootmanager = bootManager() - get_boot = self.bootmanager.get_model() - Mbox.pack_start(get_boot, True, True, 0) - label = Gtk.Label("Boot Option") - self.notebook.insert_page(Mbox, label, 2) - self.window.show_all() - self.notebook.next_page() - self.button3.set_sensitive(True) - elif page == 2: - Rbox = Gtk.VBox(False, 0) - Rbox.show() - self.summary = Summary(self.button3) - get_summary = self.summary.get_model() - Rbox.pack_start(get_summary, True, True, 0) - label = Gtk.Label("Root Password") - self.button3.set_label("Install") - self.notebook.insert_page(Rbox, label, 3) - self.window.show_all() - self.notebook.next_page() - 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, 4) - 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 == 4: - 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.types = Types() - get_types = self.types.get_model() - # self.lang = Installs() - # get_lang = self.lang.get_model() - vbox.pack_start(get_types, True, True, 0) - label = Gtk.Label("Types") - 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() diff --git a/src/gbinstall.desktop b/src/gbinstall.desktop deleted file mode 100755 index 02c552b..0000000 --- a/src/gbinstall.desktop +++ /dev/null @@ -1,15 +0,0 @@ -#!/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 gbinstall -Comment[C]=GhostBSD Installer -Name=GhostBSD Installer -Comment=GhostBSD Installer -Icon=/usr/local/lib/gbi/install.png diff --git a/src/ghostbsd-style.css b/src/ghostbsd-style.css deleted file mode 100644 index 5cfc62a..0000000 --- a/src/ghostbsd-style.css +++ /dev/null @@ -1,65 +0,0 @@ -#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; -} diff --git a/src/install-gbsd.png b/src/install-gbsd.png deleted file mode 100644 index 5748e1c..0000000 Binary files a/src/install-gbsd.png and /dev/null differ diff --git a/src/install-gbsd.svg b/src/install-gbsd.svg deleted file mode 100644 index 5112bda..0000000 --- a/src/install-gbsd.svg +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/install.png b/src/install.png deleted file mode 100644 index bad5cd0..0000000 Binary files a/src/install.png and /dev/null differ diff --git a/src/install.py b/src/install.py deleted file mode 100644 index 049f42d..0000000 --- a/src/install.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/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/gbi/" -sys.path.append(installer) -tmp = "/tmp/.gbi/" -gbi_path = "/usr/local/lib/gbi/" -sysinstall = "/usr/local/sbin/pc-sysinstall" -rcconfgbsd = "/etc/rc.conf.ghostbsd" -rcconfdbsd = "/etc/rc.conf.desktopbsd" -default_site = "/usr/local/lib/gbi/slides/welcome.html" -logo = "/usr/local/lib/gbi/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' % gbi_path, shell=True, close_fds=True) - call("rm -rf /tmp/.gbi/", shell=True, close_fds=True) - Gtk.main_quit() - else: - Popen('python2.7 %serror.py' % gbi_path, 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) - # if os.path.exists(rcconfgbsd): - slide = gbsdSlides() - # elif os.path.exists(rcconfdbsd): - # slide = dbsdSlides() - 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 diff --git a/src/installType.py b/src/installType.py deleted file mode 100644 index b234145..0000000 --- a/src/installType.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/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, Gdk -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 - -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 Types(): - - def fstype(self, radiobutton, val): - self.ne = val - 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.vbox1 - - def __init__(self): - self.vbox1 = Gtk.VBox(False, 0) - self.vbox1.show() - label = Gtk.Label("Installation Type", name="Header") - label.set_property("height-request", 40) - self.vbox1.pack_start(label, False, False, 0) - vbox = Gtk.VBox() - hbox = Gtk.HBox() - self.vbox1.pack_start(hbox, False, False, 10) - full_ufs = Gtk.RadioButton.new_with_label_from_widget(None, "UFS Full Disk Configuration") - vbox.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") - vbox.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)") - vbox.pack_start(full_zfs, False, True, 10) - full_zfs.connect("toggled", self.fstype, "zfs") - full_ufs.show() - hbox.pack_start(vbox, False, False, 50) - full_zfs.set_active(True) diff --git a/src/language.py b/src/language.py deleted file mode 100644 index c61303f..0000000 --- a/src/language.py +++ /dev/null @@ -1,154 +0,0 @@ -#!/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, Gdk -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.""" - - -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 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() - label = Gtk.Label("Welcome To GhostBSD!", name="Header") - label.set_property("height-request", 40) - self.vbox1.pack_start(label, False, False, 0) - 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('' + title + '') - 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 diff --git a/src/logo.png b/src/logo.png deleted file mode 100644 index c8f4353..0000000 Binary files a/src/logo.png and /dev/null differ diff --git a/src/partition.py b/src/partition.py deleted file mode 100644 index 4d9261c..0000000 --- a/src/partition.py +++ /dev/null @@ -1,730 +0,0 @@ -#!/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, Gdk -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 -from db_partition import efi_exist - - -# 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/gbinstall/logo.png" -Part_label = '%spartlabel' % tmp -part_schem = '%sscheme' % tmp -partitiondb = "%spartitiondb/" % tmp -boot_file = "%sboot" % tmp -ufs_Partiton_list = [] - - -cssProvider = Gtk.CssProvider() -cssProvider.load_from_path('/usr/local/lib/gbinstall/ghostbsd-style.css') -screen = Gdk.Screen.get_default() -styleContext = Gtk.StyleContext() -styleContext.add_provider_for_screen(screen, cssProvider, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) - - -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, create): - 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, create) - self.window.hide() - self.update() - - def on_add_partition(self, widget, entry, inumb, path, create): - 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, create) - self.window.hide() - self.update() - - def cancel(self, widget): - self.window.hide() - - def labelEditor(self, path, pslice, size, scheme, 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 scheme == 'GPT': - if bios_or_uefi() == "UEFI": - self.fstype.append_text("UEFI") - self.fs = "UEFI" - else: - self.fstype.append_text("BOOT") - self.fs = "BOOT" - if self.fs == "UEFI" and efi_exist(self.disk) is False: - if not os.path.exists(Part_label): - self.fstype.set_active(5) - elif len(self.prttn) == 0: - self.fstype.set_active(5) - elif self.fs == "BOOT": - if not os.path.exists(Part_label): - self.fstype.set_active(5) - elif len(self.prttn) == 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 scheme == 'GPT' and len(self.prttn) == 1: - self.mountpoint.append_text('/boot') - elif scheme == 'MBR' and len(self.prttn) == 0: - self.mountpoint.append_text('/boot') - elif scheme == 'MBR' 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 scheme == 'MBR': - button.connect("clicked", self.on_add_label, self.entry, - numb, path, True) - elif scheme == 'GPT' and self.fs == 'BOOT': - button.connect("clicked", self.on_add_partition, self.entry, - numb, path, True) - elif scheme == 'GPT' and self.fs == 'UEFI' and efi_exist(self.disk) is False: - button.connect("clicked", self.on_add_partition, self.entry, - numb, path, True) - else: - button.connect("clicked", self.on_add_partition, self.entry, - numb, path, False) - else: - if scheme == 'MBR': - button.connect("clicked", self.on_add_label, self.entry, numb, - path, False) - elif scheme == 'GPT': - 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, 'GPT', 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(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() - # Creating MBR or GPT drive - label = Gtk.Label('Select a partition scheme for this drive:') - 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(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 Partition slice - # label = Gtk.Label('Create a New Partition Slice') - # 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, 'MBR', True) - elif len(self.path) == 2 and self.slice != 'freespace': - if scheme_query(self.path) == "GPT": - self.labelEditor(self.path, self.slice, self.size, 'GPT', 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): - 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, 'MBR', 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, 'GPT', False) - else: - 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() - print(self.iter) - if self.iter is None: - return - self.path = model.get_path(self.iter) - tree_iter3 = model.get_iter(self.path[0]) - self.scheme = model.get_value(tree_iter3, 3) - self.disk = model.get_value(tree_iter3, 0) - 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) - how_many_prt = how_partition(self.path) - firstisfree = first_is_free(self.path) - if how_many_prt == 1 and firstisfree == '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.prttn = rd.readlines() - rtbt = False - for line in self.prttn: - if "/boot\n" in line: - rtbt = True - break - # If Find GPT scheme. - if os.path.exists(disk_schem): - rschm = open(disk_schem, 'r') - schm = rschm.readlines()[0] - efi = efi_exist(self.disk) - if 'GPT' in schm: - if len(self.prttn) >= 2: - if 'BOOT' in self.prttn[0]: - if rtbt is True and "/boot\n" not in self.prttn[1]: - self.button3.set_sensitive(False) - elif "/boot\n" in self.prttn[1]: - if len(self.prttn) >= 3: - if '/\n' in self.prttn[2]: - self.button3.set_sensitive(True) - else: - self.button3.set_sensitive(False) - else: - self.button3.set_sensitive(False) - elif '/\n' in self.prttn[1]: - self.button3.set_sensitive(True) - else: - self.button3.set_sensitive(False) - elif 'UEFI' in self.prttn[0] and efi is False: - if rtbt is True and "/boot\n" not in self.prttn[1]: - self.button3.set_sensitive(False) - elif "/boot\n" in self.prttn[1]: - if len(self.prttn) >= 3: - if '/\n' in self.prttn[2]: - self.button3.set_sensitive(True) - else: - self.button3.set_sensitive(False) - else: - self.button3.set_sensitive(False) - elif '/\n' in self.prttn[1]: - self.button3.set_sensitive(True) - else: - self.button3.set_sensitive(False) - elif rtbt is True and "/boot\n" not in self.prttn[1]: - self.button3.set_sensitive(False) - elif "/boot\n" in self.prttn[0] and efi is True: - if len(self.prttn) >= 2: - if '/\n' in self.prttn[1]: - self.button3.set_sensitive(True) - else: - self.button3.set_sensitive(False) - else: - self.button3.set_sensitive(False) - elif '/\n' in self.prttn[0] and efi is True: - self.button3.set_sensitive(True) - else: - self.button3.set_sensitive(False) - else: - self.button3.set_sensitive(False) - else: - if len(self.prttn) >= 1: - if "/boot\n" in self.prttn[0]: - if len(self.prttn) >= 2: - if '/\n' in self.prttn[1]: - self.button3.set_sensitive(True) - else: - self.button3.set_sensitive(False) - else: - self.button3.set_sensitive(False) - elif '/\n' in self.prttn[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.vbox1 = Gtk.VBox(False, 0) - self.vbox1.show() - # Title - label = Gtk.Label("UFS Partition Editor", name="Header") - label.set_property("height-request", 40) - self.vbox1.pack_start(label, False, False, 0) - - # Choosing disk to Select Create or delete partition. - label = Gtk.Label("Select a drive:") - 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 = Gtk.VBox(False, 10) - box2.set_border_width(10) - self.vbox1.pack_start(box2, True, True, 0) - box2.show() - box2.pack_start(sw, True, True, 0) - - box2 = Gtk.HBox(False, 10) - box2.set_border_width(0) - self.vbox1.pack_start(box2, False, False, 0) - 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.vbox1 diff --git a/src/slide-images/ghostbsd/G-logo.png b/src/slide-images/ghostbsd/G-logo.png deleted file mode 100644 index 0d56c62..0000000 Binary files a/src/slide-images/ghostbsd/G-logo.png and /dev/null differ diff --git a/src/slide-images/ghostbsd/browser.png b/src/slide-images/ghostbsd/browser.png deleted file mode 100644 index ccbdd2b..0000000 Binary files a/src/slide-images/ghostbsd/browser.png and /dev/null differ diff --git a/src/slide-images/ghostbsd/customize.png b/src/slide-images/ghostbsd/customize.png deleted file mode 100644 index c751cb9..0000000 Binary files a/src/slide-images/ghostbsd/customize.png and /dev/null differ diff --git a/src/slide-images/ghostbsd/email.png b/src/slide-images/ghostbsd/email.png deleted file mode 100644 index f8b6891..0000000 Binary files a/src/slide-images/ghostbsd/email.png and /dev/null differ diff --git a/src/slide-images/ghostbsd/help.png b/src/slide-images/ghostbsd/help.png deleted file mode 100644 index ef567f5..0000000 Binary files a/src/slide-images/ghostbsd/help.png and /dev/null differ diff --git a/src/slide-images/ghostbsd/music.png b/src/slide-images/ghostbsd/music.png deleted file mode 100644 index d337a93..0000000 Binary files a/src/slide-images/ghostbsd/music.png and /dev/null differ diff --git a/src/slide-images/ghostbsd/office.png b/src/slide-images/ghostbsd/office.png deleted file mode 100644 index bc961e9..0000000 Binary files a/src/slide-images/ghostbsd/office.png and /dev/null differ diff --git a/src/slide-images/ghostbsd/photo.png b/src/slide-images/ghostbsd/photo.png deleted file mode 100644 index 9d3ef28..0000000 Binary files a/src/slide-images/ghostbsd/photo.png and /dev/null differ diff --git a/src/slide-images/ghostbsd/social.png b/src/slide-images/ghostbsd/social.png deleted file mode 100644 index f2ad137..0000000 Binary files a/src/slide-images/ghostbsd/social.png and /dev/null differ diff --git a/src/slide-images/ghostbsd/software.png b/src/slide-images/ghostbsd/software.png deleted file mode 100644 index d147c81..0000000 Binary files a/src/slide-images/ghostbsd/software.png and /dev/null differ diff --git a/src/slide-images/ghostbsd/welcome.png b/src/slide-images/ghostbsd/welcome.png deleted file mode 100644 index e600840..0000000 Binary files a/src/slide-images/ghostbsd/welcome.png and /dev/null differ diff --git a/src/slides.py b/src/slides.py deleted file mode 100644 index 1b292f6..0000000 --- a/src/slides.py +++ /dev/null @@ -1,267 +0,0 @@ -#!/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 Software Station software manager.\n\n" - "Software Station 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 support page.") - 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) diff --git a/src/sys_handler.py b/src/sys_handler.py deleted file mode 100644 index c6ee186..0000000 --- a/src/sys_handler.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/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 diff --git a/src/use_ufs.py b/src/use_ufs.py deleted file mode 100644 index bac0427..0000000 --- a/src/use_ufs.py +++ /dev/null @@ -1,532 +0,0 @@ -#!/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, Gdk -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 = [] - -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) - - -# 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') - if bios_or_uefi() == "UEFI": - root_size = root_size - 100 - 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.vbox1 = Gtk.VBox(False, 0) - self.vbox1.show() - # Title - label = Gtk.Label("UFS Full Disk Configuration", name="Header") - label.set_property("height-request", 40) - self.vbox1.pack_start(label, False, False, 0) - # 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('Partition Scheme') - 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) - if bios_or_uefi() == "UEFI": - shemebox.set_sensitive(False) - else: - shemebox.set_sensitive(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('Swap Size(MB)') - 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_margin_left(10) - grid.set_margin_right(10) - grid.set_margin_top(10) - grid.set_margin_bottom(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) - self.vbox1.pack_start(grid, True, True, 0) - return - - def get_model(self): - del ufs_dsk_list[:] - return self.vbox1 - - 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, 5) - 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, 5) - self.button3.set_sensitive(False) diff --git a/src/use_zfs.py b/src/use_zfs.py deleted file mode 100644 index 4e1fa2d..0000000 --- a/src/use_zfs.py +++ /dev/null @@ -1,702 +0,0 @@ -#!/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, Gdk -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 = [] - - -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) - - -# 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) - if bios_or_uefi() == "UEFI": - ZFS_NUM = ZFS_NUM - 100 - 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.vbox1 = Gtk.VBox(False, 0) - self.vbox1.show() - # Title - label = Gtk.Label("ZFS Full Disk Configuration", name="Header") - label.set_property("height-request", 40) - self.vbox1.pack_start(label, False, False, 0) - # 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('Pool Type') - 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 - scheme_label = Gtk.Label('Partition Scheme') - scheme_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) - if bios_or_uefi() == "UEFI": - shemebox.set_sensitive(False) - else: - shemebox.set_sensitive(True) - # 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('Swap Size(MB)') - 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_margin_left(10) - grid.set_margin_right(10) - grid.set_margin_top(10) - grid.set_margin_bottom(10) - # grid.set_column_homogeneous(True) - # grid.set_row_homogeneous(True) - # grid.attach(Title, 1, 1, 10, 1) - grid.attach(mirror_label, 1, 2, 1, 1) - grid.attach(mirror_box, 2, 2, 1, 1) - grid.attach(pool_check, 7, 2, 2, 1) - grid.attach(self.pool, 9, 2, 2, 1) - grid.attach(self.mirrorTips, 1, 3, 8, 1) - grid.attach(zfs4kcheck, 9, 3, 2, 1) - grid.attach(sw, 1, 4, 10, 3) - grid.attach(scheme_label, 1, 9, 1, 1) - grid.attach(shemebox, 2, 9, 1, 1) - grid.attach(swp_size_label, 9, 9, 1, 1) - grid.attach(self.swap_entry, 10, 9, 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, 2, 8, 2, 1) - # grid.attach(self.passwd_label, 1, 9, 1, 1) - # grid.attach(self.password, 2, 9, 2, 1) - # grid.attach(self.strenght_label, 4, 9, 2, 1) - # grid.attach(self.vpasswd_label, 1, 10, 1, 1) - # grid.attach(self.repassword, 2, 10, 2, 1) - # grid.attach(self.img, 4, 10, 2, 1) - self.vbox1.pack_start(grid, True, True, 0) - return - - def get_model(self): - return self.vbox1 - - 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, 5) - 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, 5) - self.button3.set_sensitive(False)