summaryrefslogtreecommitdiffstats
path: root/server/modules
diff options
context:
space:
mode:
Diffstat (limited to 'server/modules')
-rw-r--r--server/modules/dnbd3-cache/etc/systemd/system/setup-dnbd3_cache.service12
l---------server/modules/dnbd3-cache/etc/systemd/system/sysinit.target.wants/setup-dnbd3_cache.service1
-rw-r--r--server/modules/dnbd3-cache/opt/openslx/dnbd3-cache/alt-servers1
-rw-r--r--server/modules/dnbd3-cache/opt/openslx/dnbd3-cache/server.conf9
-rwxr-xr-xserver/modules/dnbd3-cache/opt/openslx/scripts/systemd-setup_dnbd3_cache8
-rw-r--r--server/modules/hdd-boot/etc/systemd/system/hdd_boot.service11
l---------server/modules/hdd-boot/etc/systemd/system/multi-user.target.wants/hdd_boot.service1
-rw-r--r--server/modules/hdd-boot/opt/openslx/hdd-boot/grub.cfg146
-rwxr-xr-xserver/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot116
-rw-r--r--server/modules/local_accounts/etc/cron.d/openslx-local_accounts6
-rw-r--r--server/modules/local_accounts/etc/login.defs335
-rw-r--r--server/modules/local_accounts/etc/systemd/system/local_accounts.service9
l---------server/modules/local_accounts/etc/systemd/system/multi-user.target.wants/local_accounts.service1
-rwxr-xr-xserver/modules/local_accounts/opt/openslx/scripts/local_accounts-cron_script9
-rwxr-xr-xserver/modules/local_accounts/opt/openslx/scripts/systemd-local_accounts66
l---------server/modules/partitioner/etc/systemd/system/multi-user.target.wants/partitioner.service1
-rw-r--r--server/modules/partitioner/etc/systemd/system/partitioner.service20
-rwxr-xr-xserver/modules/partitioner/opt/openslx/scripts/systemd-partitioner497
18 files changed, 1249 insertions, 0 deletions
diff --git a/server/modules/dnbd3-cache/etc/systemd/system/setup-dnbd3_cache.service b/server/modules/dnbd3-cache/etc/systemd/system/setup-dnbd3_cache.service
new file mode 100644
index 00000000..2eaeddc4
--- /dev/null
+++ b/server/modules/dnbd3-cache/etc/systemd/system/setup-dnbd3_cache.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Setup dnbd3-server as proxy/cache daemon
+Requires=setup-dnbd3.service
+Wants=setup-partitions.service
+After=sysinit.target setup-dnbd3.service setup-partitions.service
+Before=shutdown.target
+DefaultDependencies=no
+
+[Service]
+ExecStart=/opt/openslx/scripts/systemd-setup_dnbd3_cache
+ExecStop=/opt/openslx/bin/killall dnbd3-server
+Restart=on-abort
diff --git a/server/modules/dnbd3-cache/etc/systemd/system/sysinit.target.wants/setup-dnbd3_cache.service b/server/modules/dnbd3-cache/etc/systemd/system/sysinit.target.wants/setup-dnbd3_cache.service
new file mode 120000
index 00000000..9ed23a9f
--- /dev/null
+++ b/server/modules/dnbd3-cache/etc/systemd/system/sysinit.target.wants/setup-dnbd3_cache.service
@@ -0,0 +1 @@
+../setup-dnbd3_cache.service \ No newline at end of file
diff --git a/server/modules/dnbd3-cache/opt/openslx/dnbd3-cache/alt-servers b/server/modules/dnbd3-cache/opt/openslx/dnbd3-cache/alt-servers
new file mode 100644
index 00000000..b6347315
--- /dev/null
+++ b/server/modules/dnbd3-cache/opt/openslx/dnbd3-cache/alt-servers
@@ -0,0 +1 @@
+-132.230.4.1 SLXBOX DNBD3 SERVER
diff --git a/server/modules/dnbd3-cache/opt/openslx/dnbd3-cache/server.conf b/server/modules/dnbd3-cache/opt/openslx/dnbd3-cache/server.conf
new file mode 100644
index 00000000..c0820ea1
--- /dev/null
+++ b/server/modules/dnbd3-cache/opt/openslx/dnbd3-cache/server.conf
@@ -0,0 +1,9 @@
+[dnbd3]
+#vmdkLegacyMode=TRUE
+#clientPenalty=300000
+clientPenalty=0
+basePath=/cache/export/dnbd3
+isProxy=true
+proxyPrivateOnly=true
+uplinkTimeout=5000
+
diff --git a/server/modules/dnbd3-cache/opt/openslx/scripts/systemd-setup_dnbd3_cache b/server/modules/dnbd3-cache/opt/openslx/scripts/systemd-setup_dnbd3_cache
new file mode 100755
index 00000000..705c5c89
--- /dev/null
+++ b/server/modules/dnbd3-cache/opt/openslx/scripts/systemd-setup_dnbd3_cache
@@ -0,0 +1,8 @@
+#!/bin/ash
+
+[ -d "/cache/export/dnbd3" ] || mkdir -p /cache/export/dnbd3/
+
+exec dnbd3-server -c /opt/openslx/dnbd3-cache -n
+slxlog "dnbd3-server" "Error launching dnbd3-server"
+exit 1
+
diff --git a/server/modules/hdd-boot/etc/systemd/system/hdd_boot.service b/server/modules/hdd-boot/etc/systemd/system/hdd_boot.service
new file mode 100644
index 00000000..ed4fdcb7
--- /dev/null
+++ b/server/modules/hdd-boot/etc/systemd/system/hdd_boot.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Runs the OpenSLX Hdd-boot Tool
+After=tmp.target
+Wants=tmp.target
+DefaultDependencies=no
+ConditionPathIsMountPoint=/boot
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/systemd-hdd_boot
+RemainAfterExit=yes
diff --git a/server/modules/hdd-boot/etc/systemd/system/multi-user.target.wants/hdd_boot.service b/server/modules/hdd-boot/etc/systemd/system/multi-user.target.wants/hdd_boot.service
new file mode 120000
index 00000000..515407f5
--- /dev/null
+++ b/server/modules/hdd-boot/etc/systemd/system/multi-user.target.wants/hdd_boot.service
@@ -0,0 +1 @@
+../hdd_boot.service \ No newline at end of file
diff --git a/server/modules/hdd-boot/opt/openslx/hdd-boot/grub.cfg b/server/modules/hdd-boot/opt/openslx/hdd-boot/grub.cfg
new file mode 100644
index 00000000..611b3785
--- /dev/null
+++ b/server/modules/hdd-boot/opt/openslx/hdd-boot/grub.cfg
@@ -0,0 +1,146 @@
+#
+# DO NOT EDIT THIS FILE
+#
+# It is automatically generated by grub-mkconfig using templates
+# from /etc/grub.d and settings from /etc/default/grub
+#
+
+### BEGIN /etc/grub.d/00_header ###
+if [ -s $prefix/grubenv ]; then
+ set have_grubenv=true
+ load_env
+fi
+if [ "${next_entry}" ] ; then
+ set default="${next_entry}"
+ set next_entry=
+ save_env next_entry
+ set boot_once=true
+else
+ set default="0"
+fi
+
+if [ x"${feature_menuentry_id}" = xy ]; then
+ menuentry_id_option="--id"
+else
+ menuentry_id_option=""
+fi
+
+export menuentry_id_option
+
+if [ "${prev_saved_entry}" ]; then
+ set saved_entry="${prev_saved_entry}"
+ save_env saved_entry
+ set prev_saved_entry=
+ save_env prev_saved_entry
+ set boot_once=true
+fi
+
+function savedefault {
+ if [ -z "${boot_once}" ]; then
+ saved_entry="${chosen}"
+ save_env saved_entry
+ fi
+}
+function recordfail {
+ set recordfail=1
+ if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
+}
+function load_video {
+ if [ x$feature_all_video_module = xy ]; then
+ insmod all_video
+ else
+ insmod efi_gop
+ insmod efi_uga
+ insmod ieee1275_fb
+ insmod vbe
+ insmod vga
+ insmod video_bochs
+ insmod video_cirrus
+ fi
+}
+
+if [ x$feature_default_font_path = xy ] ; then
+ font=unicode
+else
+insmod part_msdos
+insmod lvm
+insmod ext2
+set root='lvmid/ZvOK2H-W5xA-QoO2-zy2n-Sjr7-cpu8-M3zL6F/FzLrNP-IhMk-pB8d-vEEW-Jxxk-ujc7-NWSegg'
+if [ x$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root --hint='lvmid/ZvOK2H-W5xA-QoO2-zy2n-Sjr7-cpu8-M3zL6F/FzLrNP-IhMk-pB8d-vEEW-Jxxk-ujc7-NWSegg' 0bec626d-2d44-417d-acfd-83acbbcf2b34
+else
+ search --no-floppy --fs-uuid --set=root 0bec626d-2d44-417d-acfd-83acbbcf2b34
+fi
+ font="/usr/share/grub/unicode.pf2"
+fi
+
+if loadfont $font ; then
+ set gfxmode=auto
+ load_video
+ insmod gfxterm
+ set locale_dir=$prefix/locale
+ set lang=pt_PT
+ insmod gettext
+fi
+terminal_output gfxterm
+if [ "${recordfail}" = 1 ] ; then
+ set timeout=-1
+else
+ if [ x$feature_timeout_style = xy ] ; then
+ set timeout_style=menu
+ set timeout=10
+ # Fallback normal timeout code in case the timeout_style feature is
+ # unavailable.
+ else
+ set timeout=10
+ fi
+fi
+### END /etc/grub.d/00_header ###
+
+### BEGIN /etc/grub.d/05_debian_theme ###
+set menu_color_normal=white/black
+set menu_color_highlight=black/light-gray
+### END /etc/grub.d/05_debian_theme ###
+
+### BEGIN /etc/grub.d/06_mint_theme ###
+set menu_color_normal=white/black
+set menu_color_highlight=white/light-gray
+### END /etc/grub.d/06_mint_theme ###
+
+### BEGIN /etc/grub.d/10_linux ###
+### END /etc/grub.d/10_linux ###
+
+### BEGIN /etc/grub.d/10_lupin ###
+### END /etc/grub.d/10_lupin ###
+
+### BEGIN /etc/grub.d/20_linux_xen ###
+
+### END /etc/grub.d/20_linux_xen ###
+
+### BEGIN /etc/grub.d/20_memtest86+ ###
+### END /etc/grub.d/20_memtest86+ ###
+
+### BEGIN /etc/grub.d/30_os-prober ###
+set timeout_style=menu
+if [ "${timeout}" = 0 ]; then
+ set timeout=10
+fi
+### END /etc/grub.d/30_os-prober ###
+
+### BEGIN /etc/grub.d/30_uefi-firmware ###
+### END /etc/grub.d/30_uefi-firmware ###
+
+### BEGIN /etc/grub.d/40_custom ###
+# This file provides an easy way to add custom menu entries. Simply type the
+# menu entries you want to add after this comment. Be careful not to change
+# the 'exec tail' line above.
+### END /etc/grub.d/40_custom ###
+
+### BEGIN /etc/grub.d/41_custom ###
+if [ -f ${config_directory}/custom.cfg ]; then
+ source ${config_directory}/custom.cfg
+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
+ source $prefix/custom.cfg;
+fi
+### END /etc/grub.d/41_custom ###
+
diff --git a/server/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot b/server/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot
new file mode 100755
index 00000000..f975b697
--- /dev/null
+++ b/server/modules/hdd-boot/opt/openslx/scripts/systemd-hdd_boot
@@ -0,0 +1,116 @@
+#!/bin/bash
+set -x
+# Downloading all in SLX_BASE_PATH to /boot Example: Ubuntu_1404_x64
+# wget -N, update if the file has been changed
+boot_download () {
+ echo "Downloading $SLX_BASE_PATH ................."
+ wget -P /boot -N -r --tries=3 --timeout=5 --quiet -nH -l1 --no-parent --reject="index.html*" --reject="$SLX_BASE_PATH.*" $SLXSRV/$SLX_BASE_PATH #<---- ok =), but try with -nc too
+ RET=$?
+ [ $RET != 0 ] && { echo "Error - downloading 'http://$SLXSRV/$SLX_BASE_PATH/' via wget failed."; exit 1; } ||{ echo "Successfully downloaded 'http://$SLXSRV/$SLX_BASE_PATH' via wget."; return 0; }
+}
+
+# Getting informations from cmdline
+read KCL < "/proc/cmdline"
+for opts in ${KCL}; do
+ case "${opts}" in
+ slxbase=*) # BASE_PATH Example Ubuntu_1404_x64
+ SLX_BASE_PATH=${opts#slxbase=} ;;
+ slxsrv=*)
+ #SLX IP server info
+ SLXSRV=${opts#slxsrv=} ;;
+ BOOT_IMAGE=*)
+ BOOT_IMAGE=${opts} ;;
+ initrd=*)
+ initrd=${opts} ;;
+ esac
+done
+KCL=$(echo "$KCL" | sed "s|SLX_BASE_PATH|$SLX_BASE_PATH|g;s|$BOOT_IMAGE||g;s|$initrd||g")
+
+# Scan vm-store dir for vmware image xmls and copy
+if [ -d /cache/export/dnbd3 -a -d /mnt/vmstore ]; then
+ [ ! -d /boot/vmstore ] && mkdir /boot/vmstore
+ for FILE in $(find /cache/export/dnbd3 -iname "*.vmdk*" ! -iname "*map"); do
+ [ -e "${FILE}.map" ] && continue
+ image_name=$(echo $(basename "$FILE") | cut -d "." -f1)
+ cd /mnt/vmstore
+ for XML in $(grep -rIl --include "*.xml" "$image_name" .); do
+ xmldir=$(dirname $XML)
+ mkdir -p /boot/vmstore/${xmldir}
+ cp $XML /boot/vmstore/${xmldir}/
+ done
+ cd - >/dev/null
+ done
+fi
+
+# Bind mount available vmstore in /boot to /mnt/vmstore if not already present
+if ! grep -qs '/mnt/vmstore' /proc/mounts; then
+ [ ! -d /mnt/vmstore ] && mkdir -p /mnt/vmstore
+ [ -d /boot/vmstore ] && mount --bind /boot/vmstore /mnt/vmstore
+fi
+
+# if SLX_BASE_PATH already exists, just update. Does not make the menu again.
+[ -d /boot/$SLX_BASE_PATH ] && { boot_download; echo "$SLX_BASE_PATH updated"; } || { boot_download; echo "New base $SLX_BASE_PATH downloaded to HDD"; }
+
+# Installing GRUB
+
+#Find disk of /boot
+BOOT_DISK=$(df | grep /boot | awk '{print $1}' | tr -d '[0-9]' | cut -c 6-)
+BOOT_PART=$(df | grep /boot | awk '{print $1}' | tr -dc '[0-9]')
+[ -z "$BOOT_DISK" ] && { echo "BOOT DISK could not be found, exiting."; exit 1; }
+
+#Check if disk is msdos or GPT
+if sgdisk /dev/$BOOT_DISK | grep -qs 'invalid GPT'; then
+ BOOT_TYPE='msdos'
+else
+ BOOT_TYPE='gpt'
+fi
+
+if [ ! -d /boot/grub ]; then
+
+ grub-install --boot-directory=/boot /dev/$BOOT_DISK
+ update-grub-gfxpayload
+
+ RET=$?
+ [ $RET != 0 ] && { echo "Could not install GRUB"; exit 1; } || echo "GRUB successfully installed"
+
+ # First, copy grub.cfg
+ [ -e /opt/openslx/hdd-boot/grub.cfg ] && cp -r /opt/openslx/hdd-boot/grub.cfg /boot/grub/
+fi
+
+#Add new base to grub.cfg
+if ! grep -qs "menuentry '$SLX_BASE_PATH'" /boot/grub/grub.cfg; then
+
+ #GRUB ok, so lets make the menu
+ echo "BOOT DISK is $BOOT_DISK" #Just for test
+ case $BOOT_DISK in
+ sda) GRUB_DISK=hd0 ;;
+ sdb) GRUB_DISK=hd1 ;;
+ sdc) GRUB_DISK=hd2 ;;
+ sdd) GRUB_DISK=hd3 ;;
+ sde) GRUB_DISK=hd4 ;;
+ *) echo "GRUB_DISK was not found"
+ exit 1 ;;
+ esac
+
+ [ -e /boot/grub/grub.cfg ] || { echo "Could not find grub.cfg"; exit 1; }
+
+cat <<EOF >> /boot/grub/grub.cfg
+#########################
+ menuentry '$SLX_BASE_PATH' {
+ linux ($GRUB_DISK,${BOOT_TYPE}$BOOT_PART)/$SLX_BASE_PATH/kernel hdd_boot=${BOOT_DISK}$BOOT_PART $KCL
+ initrd ($GRUB_DISK,${BOOT_TYPE}$BOOT_PART)/$SLX_BASE_PATH/initramfs-stage31
+}
+#########################
+EOF
+
+fi
+
+true
+
+
+
+
+
+
+
+
diff --git a/server/modules/local_accounts/etc/cron.d/openslx-local_accounts b/server/modules/local_accounts/etc/cron.d/openslx-local_accounts
new file mode 100644
index 00000000..948ee329
--- /dev/null
+++ b/server/modules/local_accounts/etc/cron.d/openslx-local_accounts
@@ -0,0 +1,6 @@
+# Trigger scripts that checks idle status of machine and triggers actions
+
+SHELL=/bin/ash
+PATH=/usr/sbin:/usr/bin:/sbin:/bin:/opt/openslx/sbin:/opt/openslx/bin
+
+*/5 * * * * root /opt/openslx/scripts/local_accounts-cron_script
diff --git a/server/modules/local_accounts/etc/login.defs b/server/modules/local_accounts/etc/login.defs
new file mode 100644
index 00000000..9bca35e0
--- /dev/null
+++ b/server/modules/local_accounts/etc/login.defs
@@ -0,0 +1,335 @@
+#
+# /etc/login.defs - Configuration control definitions for the login package.
+#
+# Three items must be defined: MAIL_DIR, ENV_SUPATH, and ENV_PATH.
+# If unspecified, some arbitrary (and possibly incorrect) value will
+# be assumed. All other items are optional - if not specified then
+# the described action or option will be inhibited.
+#
+# Comment lines (lines beginning with "#") and blank lines are ignored.
+#
+# Modified for Linux. --marekm
+
+# REQUIRED for useradd/userdel/usermod
+# Directory where mailboxes reside, _or_ name of file, relative to the
+# home directory. If you _do_ define MAIL_DIR and MAIL_FILE,
+# MAIL_DIR takes precedence.
+#
+# Essentially:
+# - MAIL_DIR defines the location of users mail spool files
+# (for mbox use) by appending the username to MAIL_DIR as defined
+# below.
+# - MAIL_FILE defines the location of the users mail spool files as the
+# fully-qualified filename obtained by prepending the user home
+# directory before $MAIL_FILE
+#
+# NOTE: This is no more used for setting up users MAIL environment variable
+# which is, starting from shadow 4.0.12-1 in Debian, entirely the
+# job of the pam_mail PAM modules
+# See default PAM configuration files provided for
+# login, su, etc.
+#
+# This is a temporary situation: setting these variables will soon
+# move to /etc/default/useradd and the variables will then be
+# no more supported
+MAIL_DIR /var/mail
+#MAIL_FILE .mail
+
+#
+# Enable logging and display of /var/log/faillog login failure info.
+# This option conflicts with the pam_tally PAM module.
+#
+FAILLOG_ENAB yes
+
+#
+# Enable display of unknown usernames when login failures are recorded.
+#
+# WARNING: Unknown usernames may become world readable.
+# See #290803 and #298773 for details about how this could become a security
+# concern
+LOG_UNKFAIL_ENAB no
+
+#
+# Enable logging of successful logins
+#
+LOG_OK_LOGINS no
+
+#
+# Enable "syslog" logging of su activity - in addition to sulog file logging.
+# SYSLOG_SG_ENAB does the same for newgrp and sg.
+#
+SYSLOG_SU_ENAB yes
+SYSLOG_SG_ENAB yes
+
+#
+# If defined, all su activity is logged to this file.
+#
+#SULOG_FILE /var/log/sulog
+
+#
+# If defined, file which maps tty line to TERM environment parameter.
+# Each line of the file is in a format something like "vt100 tty01".
+#
+#TTYTYPE_FILE /etc/ttytype
+
+#
+# If defined, login failures will be logged here in a utmp format
+# last, when invoked as lastb, will read /var/log/btmp, so...
+#
+FTMP_FILE /var/log/btmp
+
+#
+# If defined, the command name to display when running "su -". For
+# example, if this is defined as "su" then a "ps" will display the
+# command is "-su". If not defined, then "ps" would display the
+# name of the shell actually being run, e.g. something like "-sh".
+#
+SU_NAME su
+
+#
+# If defined, file which inhibits all the usual chatter during the login
+# sequence. If a full pathname, then hushed mode will be enabled if the
+# user's name or shell are found in the file. If not a full pathname, then
+# hushed mode will be enabled if the file exists in the user's home directory.
+#
+HUSHLOGIN_FILE .hushlogin
+#HUSHLOGIN_FILE /etc/hushlogins
+
+#
+# *REQUIRED* The default PATH settings, for superuser and normal users.
+#
+# (they are minimal, add the rest in the shell startup files)
+ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
+
+#
+# Terminal permissions
+#
+# TTYGROUP Login tty will be assigned this group ownership.
+# TTYPERM Login tty will be set to this permission.
+#
+# If you have a "write" program which is "setgid" to a special group
+# which owns the terminals, define TTYGROUP to the group number and
+# TTYPERM to 0620. Otherwise leave TTYGROUP commented out and assign
+# TTYPERM to either 622 or 600.
+#
+# In Debian /usr/bin/bsd-write or similar programs are setgid tty
+# However, the default and recommended value for TTYPERM is still 0600
+# to not allow anyone to write to anyone else console or terminal
+
+# Users can still allow other people to write them by issuing
+# the "mesg y" command.
+
+TTYGROUP tty
+TTYPERM 0600
+
+#
+# Login configuration initializations:
+#
+# ERASECHAR Terminal ERASE character ('\010' = backspace).
+# KILLCHAR Terminal KILL character ('\025' = CTRL/U).
+# UMASK Default "umask" value.
+#
+# The ERASECHAR and KILLCHAR are used only on System V machines.
+#
+# UMASK is the default umask value for pam_umask and is used by
+# useradd and newusers to set the mode of the new home directories.
+# 022 is the "historical" value in Debian for UMASK
+# 027, or even 077, could be considered better for privacy
+# There is no One True Answer here : each sysadmin must make up his/her
+# mind.
+#
+# Prefix these values with "0" to get octal, "0x" to get hexadecimal.
+#
+ERASECHAR 0177
+KILLCHAR 025
+UMASK 022
+
+#
+# Password aging controls:
+#
+# PASS_MAX_DAYS Maximum number of days a password may be used.
+# PASS_MIN_DAYS Minimum number of days allowed between password changes.
+# PASS_WARN_AGE Number of days warning given before a password expires.
+#
+PASS_MAX_DAYS 99999
+PASS_MIN_DAYS 0
+PASS_WARN_AGE 7
+
+#
+# Min/max values for automatic uid selection in useradd
+#
+UID_MIN 2000
+UID_MAX 60000
+# System accounts
+#SYS_UID_MIN 100
+#SYS_UID_MAX 999
+
+#
+# Min/max values for automatic gid selection in groupadd
+#
+GID_MIN 2000
+GID_MAX 60000
+# System accounts
+#SYS_GID_MIN 100
+#SYS_GID_MAX 999
+
+#
+# Max number of login retries if password is bad. This will most likely be
+# overriden by PAM, since the default pam_unix module has it's own built
+# in of 3 retries. However, this is a safe fallback in case you are using
+# an authentication module that does not enforce PAM_MAXTRIES.
+#
+LOGIN_RETRIES 5
+
+#
+# Max time in seconds for login
+#
+LOGIN_TIMEOUT 60
+
+#
+# Which fields may be changed by regular users using chfn - use
+# any combination of letters "frwh" (full name, room number, work
+# phone, home phone). If not defined, no changes are allowed.
+# For backward compatibility, "yes" = "rwh" and "no" = "frwh".
+#
+CHFN_RESTRICT rwh
+
+#
+# Should login be allowed if we can't cd to the home directory?
+# Default in no.
+#
+DEFAULT_HOME yes
+
+#
+# If defined, this command is run when removing a user.
+# It should remove any at/cron/print jobs etc. owned by
+# the user to be removed (passed as the first argument).
+#
+#USERDEL_CMD /usr/sbin/userdel_local
+
+#
+# If set to yes, userdel will remove the userĀ“s group if it contains no
+# more members, and useradd will create by default a group with the name
+# of the user.
+#
+# Other former uses of this variable such as setting the umask when
+# user==primary group are not used in PAM environments, such as Debian
+#
+USERGROUPS_ENAB yes
+
+#
+# Instead of the real user shell, the program specified by this parameter
+# will be launched, although its visible name (argv[0]) will be the shell's.
+# The program may do whatever it wants (logging, additional authentification,
+# banner, ...) before running the actual shell.
+#
+# FAKE_SHELL /bin/fakeshell
+
+#
+# If defined, either full pathname of a file containing device names or
+# a ":" delimited list of device names. Root logins will be allowed only
+# upon these devices.
+#
+# This variable is used by login and su.
+#
+#CONSOLE /etc/consoles
+#CONSOLE console:tty01:tty02:tty03:tty04
+
+#
+# List of groups to add to the user's supplementary group set
+# when logging in on the console (as determined by the CONSOLE
+# setting). Default is none.
+#
+# Use with caution - it is possible for users to gain permanent
+# access to these groups, even when not logged in on the console.
+# How to do it is left as an exercise for the reader...
+#
+# This variable is used by login and su.
+#
+#CONSOLE_GROUPS floppy:audio:cdrom
+
+#
+# If set to "yes", new passwords will be encrypted using the MD5-based
+# algorithm compatible with the one used by recent releases of FreeBSD.
+# It supports passwords of unlimited length and longer salt strings.
+# Set to "no" if you need to copy encrypted passwords to other systems
+# which don't understand the new algorithm. Default is "no".
+#
+# This variable is deprecated. You should use ENCRYPT_METHOD.
+#
+#MD5_CRYPT_ENAB no
+
+#
+# If set to MD5 , MD5-based algorithm will be used for encrypting password
+# If set to SHA256, SHA256-based algorithm will be used for encrypting password
+# If set to SHA512, SHA512-based algorithm will be used for encrypting password
+# If set to DES, DES-based algorithm will be used for encrypting password (default)
+# Overrides the MD5_CRYPT_ENAB option
+#
+# Note: It is recommended to use a value consistent with
+# the PAM modules configuration.
+#
+ENCRYPT_METHOD SHA512
+
+#
+# Only used if ENCRYPT_METHOD is set to SHA256 or SHA512.
+#
+# Define the number of SHA rounds.
+# With a lot of rounds, it is more difficult to brute forcing the password.
+# But note also that it more CPU resources will be needed to authenticate
+# users.
+#
+# If not specified, the libc will choose the default number of rounds (5000).
+# The values must be inside the 1000-999999999 range.
+# If only one of the MIN or MAX values is set, then this value will be used.
+# If MIN > MAX, the highest value will be used.
+#
+# SHA_CRYPT_MIN_ROUNDS 5000
+# SHA_CRYPT_MAX_ROUNDS 5000
+
+################# OBSOLETED BY PAM ##############
+# #
+# These options are now handled by PAM. Please #
+# edit the appropriate file in /etc/pam.d/ to #
+# enable the equivelants of them.
+#
+###############
+
+#MOTD_FILE
+#DIALUPS_CHECK_ENAB
+#LASTLOG_ENAB
+#MAIL_CHECK_ENAB
+#OBSCURE_CHECKS_ENAB
+#PORTTIME_CHECKS_ENAB
+#SU_WHEEL_ONLY
+#CRACKLIB_DICTPATH
+#PASS_CHANGE_TRIES
+#PASS_ALWAYS_WARN
+#ENVIRON_FILE
+#NOLOGINS_FILE
+#ISSUE_FILE
+#PASS_MIN_LEN
+#PASS_MAX_LEN
+#ULIMIT
+#ENV_HZ
+#CHFN_AUTH
+#CHSH_AUTH
+#FAIL_DELAY
+
+################# OBSOLETED #######################
+# #
+# These options are no more handled by shadow. #
+# #
+# Shadow utilities will display a warning if they #
+# still appear. #
+# #
+###################################################
+
+# CLOSE_SESSIONS
+# LOGIN_STRING
+# NO_PASSWORD_CONSOLE
+# QMAIL_DIR
+
+
+
diff --git a/server/modules/local_accounts/etc/systemd/system/local_accounts.service b/server/modules/local_accounts/etc/systemd/system/local_accounts.service
new file mode 100644
index 00000000..37488705
--- /dev/null
+++ b/server/modules/local_accounts/etc/systemd/system/local_accounts.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Runs the OpenSLX Create Users Tool
+Wants=display-manager.service getty@tty1.service getty@ttyUSB0.service
+Before=display-manager.service getty@tty1.service getty@ttyUSB0.service
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/systemd-local_accounts
+RemainAfterExit=yes
diff --git a/server/modules/local_accounts/etc/systemd/system/multi-user.target.wants/local_accounts.service b/server/modules/local_accounts/etc/systemd/system/multi-user.target.wants/local_accounts.service
new file mode 120000
index 00000000..578ecc01
--- /dev/null
+++ b/server/modules/local_accounts/etc/systemd/system/multi-user.target.wants/local_accounts.service
@@ -0,0 +1 @@
+../../../../etc/systemd/system/local_accounts.service \ No newline at end of file
diff --git a/server/modules/local_accounts/opt/openslx/scripts/local_accounts-cron_script b/server/modules/local_accounts/opt/openslx/scripts/local_accounts-cron_script
new file mode 100755
index 00000000..8d38401a
--- /dev/null
+++ b/server/modules/local_accounts/opt/openslx/scripts/local_accounts-cron_script
@@ -0,0 +1,9 @@
+#!/bin/ash
+
+# create .patches for next session
+
+if [ -d /home/openslx ]; then
+ for file in passwd shadow group; do
+ diff -u /home/openslx/.$file.backup /etc/$file > /home/openslx/.$file.patch
+ done
+fi
diff --git a/server/modules/local_accounts/opt/openslx/scripts/systemd-local_accounts b/server/modules/local_accounts/opt/openslx/scripts/systemd-local_accounts
new file mode 100755
index 00000000..5cabd4fd
--- /dev/null
+++ b/server/modules/local_accounts/opt/openslx/scripts/systemd-local_accounts
@@ -0,0 +1,66 @@
+#!/bin/ash
+
+. /opt/openslx/config || { echo "Could not source config!"; exit 23; }
+
+#generate new user with useradd and insert password in /etc/shadow if exists
+create_user(){
+ local username="$1"
+ local password="$2"
+ uset IFS
+
+ #if the users doesn't exists, create him without the password
+ if useradd -s /bin/bash -m "$username" -K UID_MIN=1000 -K GID_MIN=1000; then
+ if [ -n "$password" ]; then
+ #set the password in the /etc/shadow file
+ sed -i "s#^${username}:[^:]*:#${username}:${password}:#" "/etc/shadow"
+ fi
+ else
+ echo 'user ${username} already exists'
+ #if the user already exists, check if the password has changed
+ if [ -n "$password" ] && [ $(grep ^${username}: /etc/shadow | cut -d ':' -f2) != "$password" ]; then
+ echo "User password changed, updating /etc/shadow to new one"
+ #set the password in the /etc/shadow file
+ sed -i "s#^${username}:[^:]*:#${username}:${password}:#" "/etc/shadow"
+ fi
+ fi
+}
+
+# check if the /home partition exists
+if mount | grep "/home" > /dev/null; then
+ echo "/home partition found"
+
+ #try to create the 'openslx' user in whose home dir backups and patch files will be stored
+ if useradd -s /bin/bash -m openslx -K UID_MIN=1000 -K GID_MIN=1000; then
+ echo "user openslx created"
+ #set the password in the /etc/shadow file
+ sed -i "s#^openslx:[^:]*:#openslx:$OPENSLX_PASS:#" "/etc/shadow"
+ fi
+
+ #create the accounts specified in the SLX_USERS config.
+ for line in $SLX_USERS; do
+ IFS=,
+ set $line
+ create_user $1 $2
+ done
+
+ #patch passwd, shadow and group with changes the local admin made in that machine
+ for file in passwd shadow group; do
+ #backup files before patching to save slxbox state
+ echo "Backing up /etc/${file} at /home/openslx/.${file}.backup"
+ cp /etc/${file} /home/openslx/.${file}.backup
+
+ #apply patch of users created by the admin in the last session.
+ if [ -e /home/openslx/.${file}.patch ]; then
+ patch /etc/${file} < /home/openslx/.${file}.patch
+ fi
+ done
+
+else
+ #if no /home partition was found, will create the user but won't do the patch and backup.
+ echo "No /home partition found on hdd. Creating non permanent users from slxbox."
+ for line in $SLX_USERS; do # create the accounts specified in the SLX_USERS config.
+ IFS=,
+ set $line
+ create_user $1 $2
+ done
+fi
diff --git a/server/modules/partitioner/etc/systemd/system/multi-user.target.wants/partitioner.service b/server/modules/partitioner/etc/systemd/system/multi-user.target.wants/partitioner.service
new file mode 120000
index 00000000..48defa3e
--- /dev/null
+++ b/server/modules/partitioner/etc/systemd/system/multi-user.target.wants/partitioner.service
@@ -0,0 +1 @@
+../partitioner.service \ No newline at end of file
diff --git a/server/modules/partitioner/etc/systemd/system/partitioner.service b/server/modules/partitioner/etc/systemd/system/partitioner.service
new file mode 100644
index 00000000..85b41597
--- /dev/null
+++ b/server/modules/partitioner/etc/systemd/system/partitioner.service
@@ -0,0 +1,20 @@
+[Unit]
+Description=Runs the OpenSLX Partitioning Tool
+After=killsplash.service
+After=systemd-vconsole-setup.service
+Before=display-manager.service getty@tty1.service getty@ttyUSB0.service
+Before=serial-getty@ttyS0.service serial-getty@ttyO0.service serial-getty@ttyO2.service
+Before=serial-getty@ttyAMA0.service serial-getty@ttymxc0.service serial-getty@ttymxc3.service
+Conflicts=killsplash.service
+ConditionKernelCommandLine=partitioner
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/systemd-partitioner
+TimeoutSec=0
+RemainAfterExit=yes
+SysVStartPriority=99
+StandardInput=tty
+StandardOutput=tty
+StandardError=syslog
+
diff --git a/server/modules/partitioner/opt/openslx/scripts/systemd-partitioner b/server/modules/partitioner/opt/openslx/scripts/systemd-partitioner
new file mode 100755
index 00000000..d8fa0c6d
--- /dev/null
+++ b/server/modules/partitioner/opt/openslx/scripts/systemd-partitioner
@@ -0,0 +1,497 @@
+#!/bin/ash
+# Copyright (c) 2013 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found under http://openslx.org
+#
+# Local hard disk autodetection script for OpenSLX linux stateless clients,
+# detecting swap and special partitions
+
+#############################################################################
+
+perror () {
+ echo "ERROR: $@" 1>&2
+ if [ "$SLX_AUTOMATIC_PARTITIONING" != "yes" ]; then
+ dialog --title "ERROR" --stdout --msgbox "$@" 15 60
+ else
+ dialog --title "ERROR" --no-cancel --stdout --pause "$@\n\nReboot in:" 15 60 600
+ reboot
+ fi
+ exit 1
+}
+
+pwarning () {
+ echo "WARNING: $@" 1>&2
+ if [ "$SLX_AUTOMATIC_PARTITIONING" != "yes" ]; then
+ dialog --title "WARNING" --stdout --msgbox "$@" 15 60
+ else
+ dialog --title "WARNING" --stdout --infobox "$@" 15 60
+ sleep 5
+ fi
+}
+
+. /opt/openslx/config || perror "Could not source config."
+
+#set -x
+#exec > /log 2>&1
+
+
+#--------------------------------------------------------------------------------------
+#Gathering partition information
+
+# BLOCKSIZE=$(sfdisk -l /dev/$SLX_CHOOSEN_DISK | grep -o -e "blocks of [0-9]* bytes" | cut -d ' ' -f3)
+BLOCKSIZE=1024
+
+# pick the size of a sector (usually 512 bytes)
+# SECTORSIZE=$(sfdisk /dev/$SLX_CHOOSEN_DISK -l -u S 2> /dev/null | grep Units | cut -d ' ' -f5)
+SECTORSIZE=512
+
+# Partition that should be set as extended partition (only partitions 2-4 can be extended partitions)
+EXTENDED_PARTITION_NR=4
+
+PARTITIONSPATH="/proc/partitions"
+# picking disk that will be used
+DISKS=$(cat $PARTITIONSPATH | tr -s ' ' | cut -d ' ' -f5 | grep -e "[a-z]$")
+if [ -z "$DISKS" ]; then
+ perror "Can't find an hard disk."
+fi
+#--------------------------------------------------------------------------------------
+
+define_partition_table() {
+ if [ -z "$SLX_PARTITION_TABLE" ]; then
+ SLX_PARTITION_TABLE='
+ 44,10G,/tmp
+ 45,10G,/var/scratch
+ 82,4G'
+ pwarning "You didn't define a partition table in config. Using default partition table:\n$SLX_PARTITION_TABLE"
+ fi
+}
+
+size_conv() {
+ [ $(echo "$1<1024" | bc) -eq 1 ] && { echo "$1 B"; exit 0; }
+ local result="$(echo $1 | awk '{ sum=$1; hum[1024^3]="GB"; hum[1024^2]="MB"; hum[1024]="KB";
+ for (x=1024^3; x>=1024; x/=1024){
+ if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break }
+ }
+ }')"
+ echo $result
+}
+
+choose_disk() {
+ local disk_number=$(echo $DISKS | tr ' ' \\n | wc -l)
+ if [ "$SLX_AUTOMATIC_PARTITIONING" = "yes" ]; then
+ if [ -n "$SLX_CHOOSEN_DISK" ]; then
+ echo $DISKS | grep -wq "$SLX_CHOOSEN_DISK" || perror "ERROR: Automatic partitioning enabled, but in config specified $SLX_CHOOSEN_DISK was not found."
+ elif [ "$disk_number" -eq 1 ]; then
+ SLX_CHOOSEN_DISK=$DISKS
+ pwarning "Automatic partitioning enabled, but SLX_CHOOSEN_DISK not specified in config. Choosing only existing disk: $DISKS for partitioning."
+ else
+ perror "Automatic partitioning enabled, but SLX_CHOOSEN_DISK not specified in config. More than one disk exists, please specify disk in config and run again."
+ fi
+ else
+ local dialog_string="Existing disks with partition tables:\n\n"
+ local disksize=""
+ local freespace=0
+ local parts=""
+ local partsize=0
+ local used=0
+ local options=""
+
+ for disk in $DISKS; do
+ disksize=$(echo "$(cat $PARTITIONSPATH | grep -e $disk$ | tr -s ' ' | cut -d ' ' -f4)*$BLOCKSIZE" | bc)
+ parts=$(cat $PARTITIONSPATH | grep -e $disk[0-9] | tr -s ' ' | cut -d ' ' -f5)
+ dialog_string="${dialog_string}$disk $(size_conv $disksize)\n"
+ used=0
+ options="${options}$disk $disk "
+
+ for part in $parts; do
+ partsize=$(echo "$(cat $PARTITIONSPATH | grep -e $part$ | tr -s ' ' | cut -d ' ' -f4)*$BLOCKSIZE" | bc)
+ used=$(echo "$used+$partsize" | bc)
+ dialog_string="${dialog_string} $part $(size_conv $partsize)\n"
+ done
+
+ dialog_string=$dialog_string"--------------------------------\n"
+ freespace=$(echo "$disksize-$used" | bc)
+ dialog_string="${dialog_string}Used $(size_conv $used)\n"
+ dialog_string="${dialog_string}Free $(size_conv $freespace)\n\n"
+ done
+
+ if [ $(echo $DISKS | tr ' ' \\n | wc -l) -gt 0 ]; then
+ SLX_CHOOSEN_DISK=$(echo $options | xargs dialog --title "Choose a disk to partition:" --no-tags --cr-wrap --no-collapse --stdout --menu "${dialog_string}" 0 0 0)
+ if [ -z $SLX_CHOOSEN_DISK ]; then
+ pwarning "Partitioning aborted by user."
+ exit 1
+ fi
+ else
+ perror "Can't find a hard disk."
+ fi
+ fi
+ CHOOSEN_DISK_SIZE=$(echo "$(cat $PARTITIONSPATH | grep -e $SLX_CHOOSEN_DISK$ | tr -s ' ' | cut -d ' ' -f4)*$BLOCKSIZE" | bc)
+ CHOOSEN_DISK_PARTS=$(cat $PARTITIONSPATH | grep -e $SLX_CHOOSEN_DISK[0-9] | tr -s ' ' | cut -d ' ' -f5)
+}
+
+check_disk_size() {
+ # check if the choosen disk is greater than the new partition table size.
+ local part_number=$(echo $SLX_PARTITION_TABLE | wc -w)
+ local part_space=$(echo $SLX_PARTITION_TABLE | grep -oE '[0-9]+G' | awk '{ SUM += $0 } END { print SUM }')
+ NEEDED_DISK_SPACE=$(echo "$part_space*1024*1024*1024+$part_number*1024*1024" | bc)
+
+ if [ $(echo "$CHOOSEN_DISK_SIZE<$NEEDED_DISK_SPACE" | bc) -eq 1 ]; then
+ perror "Insufficient space on disk /dev/$SLX_CHOOSEN_DISK\n DISK SIZE: $(size_conv $CHOOSEN_DISK_SIZE)\n REQUIRED SIZE: $(size_conv $NEEDED_DISK_SPACE)"
+ fi
+}
+
+select_partition_type() {
+ # choosing the partition type (MSDOS or GPT) if it wasn't set in config file
+ if [ -z "$SLX_PARTITION_TYPE" ]; then
+ if [ "$SLX_AUTOMATIC_PARTITIONING" = "yes" ]; then
+ pwarning "SLX_PARTITION_TYPE not defined in config, using default: msdos"
+ SLX_PARTITION_TYPE=msdos
+ else
+ SLX_PARTITION_TYPE=$(dialog --no-tags --title "Choose a partition type:" --menu --stdout "Partitions types:" 0 0 0 "msdos" " MSDOS " "GPT" " GPT ")
+ if [ -z $SLX_PARTITION_TYPE ]; then
+ pwarning "Partitioning aborted by user."
+ exit 1
+ fi
+ fi
+ fi
+}
+
+confirm_partitioning() {
+ local dialog_string="New partition table after partitioning:\n\n"
+ local counter=1
+ local id=0
+ local size=0
+ local mountpoint=""
+ local bootable=0
+ local part_type="Primary"
+ for part in $SLX_PARTITION_TABLE; do
+ IFS=,
+ set $part
+
+ id=$1
+ shift
+ size=${1%G}
+ shift
+ [ -n $1 ] && mountpoint=$1
+ shift
+ case "$*" in
+ *bootable*) bootable=1 ;;
+ *) bootable=0 ;;
+ esac
+
+ [ "$id" = "82" ] && mountpoint="swap"
+
+ if [ $SLX_PARTITION_TYPE = 'GPT' ]; then
+ #update dialog status
+ dialog_string="${dialog_string}${mountpoint} (/dev/"${SLX_CHOOSEN_DISK}${counter}")\n"
+ if [ "${id}" = "82" ]; then
+ dialog_string="${dialog_string} GUID: 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F\n"
+ elif [ "${id}" = "83" ]; then
+ dialog_string="${dialog_string} GUID: 0FC63DAF-8483-4772-8E79-3D69D8477DE4\n"
+ else
+ dialog_string="${dialog_string} GUID: "$id"000000-0000-0000-0000-000000000000\n"
+ fi
+ dialog_string="${dialog_string} Size: "$size" GB\n"
+ else
+ if [ $counter -eq $EXTENDED_PARTITION_NR ]; then
+ part_type="Logical"
+ counter=$(($counter+1))
+ fi
+ #update dialog
+ dialog_string="${dialog_string}$mountpoint (/dev/${SLX_CHOOSEN_DISK}$counter)\n"
+ dialog_string="${dialog_string} Type: $part_type\n"
+ dialog_string="${dialog_string} ID: $id\n"
+ dialog_string="${dialog_string} Size: $size GB\n"
+ fi
+
+ counter=$(($counter+1))
+ done
+ unset IFS
+
+ dialog_string="${dialog_string}\nAll existing partitions on /dev/$SLX_CHOOSEN_DISK will be deleted, continue?"
+
+ # asking confirmation to create the partitions
+ dialog --title "WARNING" --stdout --defaultno --yesno "$dialog_string" 0 0
+ if [ $? -eq 1 ]; then
+ pwarning "Partitioning aborted by user."
+ exit 1
+ fi
+}
+
+# function to create gpt type partition tables (uses sgdisk)
+partition_disk_gpt() {
+ # delete partition table
+ sgdisk -Z /dev/$SLX_CHOOSEN_DISK > /dev/null 2>&1 || perror "Error erasing old partition table"
+
+ #set dialog
+ dialog_string="Partitions created:\n\n"
+ echo "0" | dialog --title "Partitioner" --stdout --gauge "$dialog_string" 0 0 0
+
+ # loop that will create each GPT partition, change GUIDS, change names, and set bootable flags.
+ local counter=1
+ local part_number=$(echo $SLX_PARTITION_TABLE | wc -w)
+ local id=0
+ local size=0
+ local mountpoint=""
+ local bootable=0
+ for part in $SLX_PARTITION_TABLE; do
+ IFS=,
+ set $part
+
+ id=$1
+ shift
+ size=${1%G}
+ shift
+ [ -n $1 ] && mountpoint=$1
+ shift
+ case "$*" in
+ *bootable*) bootable=1 ;;
+ *) bootable=0 ;;
+ esac
+
+ #create boot partition and set boot flag
+ if [ "$bootable" -eq 1 ]; then
+ sgdisk /dev/${SLX_CHOOSEN_DISK} -n ${counter}:0:+1M 1>&2 || perror "Error setting size of GPT partition ${SLX_CHOOSEN_DISK}${counter}"
+ sgdisk /dev/${SLX_CHOOSEN_DISK} -t ${counter}:21686148-6449-6E6F-744E-656564454649 1>&2 || perror "Error setting id ${id} of GPT partition ${SLX_CHOOSEN_DISK}${counter}"
+ sgdisk /dev/${SLX_CHOOSEN_DISK} -A ${counter}:set:2 1>&2 || perror "Error setting boot flag for GPT partition ${SLX_CHOOSEN_DISK}${counter}"
+ dialog_string="${dialog_string}Special bootloader partition (/dev/${SLX_CHOOSEN_DISK}${counter})\n"
+ dialog_string="${dialog_string} GUID: 21686148-6449-6E6F-744E-656564454649\n"
+ dialog_string="${dialog_string} Size: 1 MB\n"
+ counter=$(($counter+1))
+ part_number=$(($part_number+1))
+ fi
+
+ #set size of partition
+ sgdisk /dev/${SLX_CHOOSEN_DISK} -n ${counter}:0:+${size}G 1>&2 || perror "Error setting size of GPT partition ${SLX_CHOOSEN_DISK}${counter}"
+
+ #set id of partition
+ if [ "${id}" = "82" ] || [ "${id}" = "83" ]; then
+ sgdisk /dev/${SLX_CHOOSEN_DISK} -t ${counter}:${id}00 1>&2 || perror "Error setting id ${id} of GPT partition ${SLX_CHOOSEN_DISK}${counter}"
+ else
+ sgdisk /dev/${SLX_CHOOSEN_DISK} -t ${counter}:${id}000000-0000-0000-0000-000000000000 -c ${counter}:\"${mountpoint}\" 1>&2 || perror "Error setting id ${id} of GPT partition ${SLX_CHOOSEN_DISK}${counter}"
+ fi
+
+ #update dialog status
+ [ "$id" = "82" ] && mountpoint="swap"
+ dialog_string="${dialog_string}${mountpoint} (/dev/${SLX_CHOOSEN_DISK}${counter})\n"
+ if [ "${id}" = "82" ]; then
+ dialog_string="${dialog_string} GUID: 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F\n"
+ elif [ "${id}" = "83" ]; then
+ dialog_string="${dialog_string} GUID: 0FC63DAF-8483-4772-8E79-3D69D8477DE4\n"
+ else
+ dialog_string="${dialog_string} GUID: ${id}000000-0000-0000-0000-000000000000\n"
+ fi
+ dialog_string="${dialog_string} Size: ${size} GB\n"
+ echo $(echo "(100/$part_number)*$counter" | bc) | dialog --title "Partitioner" --stdout --gauge "${dialog_string}" 0 0 0
+
+ counter=$(($counter+1))
+ done
+ unset IFS
+
+ if [ "$SLX_AUTOMATIC_PARTITIONING" != "yes" ]; then
+ dialog --title "Partitioner" --stdout --msgbox "$dialog_string" 0 0
+ fi
+}
+
+#function to create msdos type partition tables (uses sfdisk)
+partition_disk_msdos(){
+ # delete partition table
+ sgdisk -Z /dev/$SLX_CHOOSEN_DISK > /dev/null 2>&1 || perror "Error erasing old partition table"
+
+ #set dialog
+ dialog_string="Partitions created:\n\n"
+
+ # constructing the sfdisk input file
+ echo "unit: sectors"> /tmp/partitiontable.tmp
+
+ # loop that will create each GPT partition, change GUIDS, change names, and set bootable flags.
+ local counter=1
+ local id=0
+ local size=0
+ local mountpoint=""
+ local bootable=0
+ local part_type="Primary"
+ local start=$(echo "1*1024*1024/$SECTORSIZE" | bc)
+ for part in $SLX_PARTITION_TABLE; do
+ IFS=,
+ set $part
+
+ id=$1
+ shift
+ size=${1%G}
+ shift
+ [ -n $1 ] && mountpoint=$1
+ shift
+ case "$*" in
+ *bootable*) bootable=1 ;;
+ *) bootable=0 ;;
+ esac
+
+ if [ $counter -eq $EXTENDED_PARTITION_NR ]; then
+ echo "/dev/${SLX_CHOOSEN_DISK}$counter : start= $start, size= $(echo "${CHOOSEN_DISK_SIZE}/$SECTORSIZE-1" | bc), Id= 5" >> /tmp/partitiontable.tmp
+ part_type="Logical"
+ start=$(echo "$start+1*1024*1024/$SECTORSIZE" | bc)
+ counter=$(($counter+1))
+ fi
+
+ size_bytes=$(echo "${size}*1024*1024*1024/$SECTORSIZE" | bc)
+
+ if [ "$bootable" -eq 1 ]; then
+ echo "/dev/${SLX_CHOOSEN_DISK}$counter : start= $start, size= $size_bytes, Id= $id, bootable " >> /tmp/partitiontable.tmp
+ else
+ echo "/dev/${SLX_CHOOSEN_DISK}$counter : start= $start, size= $size_bytes, Id= $id" >> /tmp/partitiontable.tmp
+ fi
+
+ start=$(echo "$start+$size_bytes+1*1024*1024/$SECTORSIZE" |bc)
+
+ #update dialog
+ [ "$id" = "82" ] && mountpoint="swap"
+ dialog_string="${dialog_string}$mountpoint (/dev/${SLX_CHOOSEN_DISK}$counter)\n"
+ dialog_string="${dialog_string} Type: $part_type\n"
+ dialog_string="${dialog_string} ID: $id\n"
+ dialog_string="${dialog_string} Size: $size GB\n"
+
+ counter=$(($counter+1))
+ done
+ unset IFS
+
+ sfdisk -q --no-reread -f /dev/${SLX_CHOOSEN_DISK} < /tmp/partitiontable.tmp 1>&2 || return 0
+ # rm -f /tmp/partitiontable.tmp
+
+ if [ "$SLX_AUTOMATIC_PARTITIONING" != "yes" ]; then
+ dialog --title "Partitioner" --stdout --msgbox "$dialog_string" 0 0
+ else
+ dialog --title "Partitioner" --stdout --infobox "$dialog_string" 0 0
+ sleep 5
+ fi
+}
+
+
+define_partition_table
+choose_disk
+select_partition_type
+if [ "$SLX_AUTOMATIC_PARTITIONING" != "yes" ]; then
+ confirm_partitioning
+fi
+check_disk_size
+
+if [ $SLX_PARTITION_TYPE = 'GPT' ]; then
+ partition_disk_gpt
+else
+ partition_disk_msdos
+fi
+
+if [ "$SLX_AUTOMATIC_PARTITIONING" != "yes" ]; then
+ #reboot prompt
+ dialog --title "reboot computer" --stdout --yes-label "Reboot" --no-label "Continue" --yesno "For changes to take effect you have to reboot your machine." 5 65
+ [ $? -eq 0 ] && reboot || exit 0
+else
+ reboot
+fi
+
+####################### CODE FOR THE PRESERVATION OF EXISTING PARTITIONS (EXPERIMENTAL) #########################
+#elif [ $(sfdisk -d /dev/$SLX_CHOOSEN_DISK 2> /dev/null | grep $SLX_CHOOSEN_DISK'1' | tr -s ' ' | cut -d ' ' -f7 | cut -d '=' -f2) = 'ee' ]; then
+## finding existent partitions in GPT
+# echo 'GPT'
+# NONEXISTENT_PARTITIONS=0
+# for (( i = 1; i < $COUNTER; i++ )); do
+# if [ $i -ne 4 ]; then
+# for PART in $PARTS; do
+# if [ "${PARTTBL["$SLX_CHOOSEN_DISK$i/id"]}" = "82" ]; then
+# sgdisk /dev/$SLX_CHOOSEN_DISK -i ${PART:3} 2> /dev/null | grep "0657FD6D-A4AB-43C4-84E5-0933C84B4F4F" > /dev/null
+# elif [ "${PARTTBL["$SLX_CHOOSEN_DISK$i/id"]}" = "83" ]; then
+# sgdisk /dev/$SLX_CHOOSEN_DISK -i ${PART:3} 2> /dev/null | grep "0FC63DAF-8483-4772-8E79-3D69D8477DE4" > /dev/null
+# else
+# sgdisk /dev/$SLX_CHOOSEN_DISK -i ${PART:3} 2> /dev/null | grep ${PARTTBL["$SLX_CHOOSEN_DISK$i/id"]}"000000-0000-0000-0000-000000000000" > /dev/null
+# fi
+# if [ $? -eq 0 ]; then
+# PARTTBL["$SLX_CHOOSEN_DISK$i/exists"]=$PART
+# NEEDED_SPACE=$(($NEEDED_SPACE-${PARTTBL["$SLX_CHOOSEN_DISK$i/size"]}*1024*1024*1024))
+# break
+# fi
+# done
+# if [[ ${PARTTBL["$SLX_CHOOSEN_DISK$i/exists"]} = "0" ]]; then
+# NONEXISTENT_PARTITIONS=$(($NONEXISTENT_PARTITIONS+1))
+# fi
+# fi
+# done
+# # checking if there's sufficient space for the new partitions.
+# if [[ $FREESPACE -lt $NEEDED_SPACE ]]; then
+# dialog --msgbox "ERROR: Insufficient free space in disk /dev/$SLX_CHOOSEN_DISK." 6 40
+# exit 1
+# fi
+# if [[ $NONEXISTENT_PARTITIONS -eq 0 ]]; then
+# dialog_string="All your requested partitions already exists.\n\n"
+# dialog_string=$dialog_string"Partition ID\n"
+# for (( i = 1; i < $COUNTER; i++ )); do
+# if [[ $i -ne 4 ]]; then
+# dialog_string=$dialog_string"${PARTTBL["$SLX_CHOOSEN_DISK$i/exists"]} ${PARTTBL["$SLX_CHOOSEN_DISK$i/id"]}\n"
+# fi
+# done
+# else
+# dialog_string="Creating partitions...\n\n"
+# echo "0" | dialog --gauge "$dialog_string" 0 0 0
+# CREATED=0
+# for (( i = 1; i < $COUNTER; i++ )); do
+# j=1
+# if [[ $i -ne 4 ]]; then
+# if [[ "${PARTTBL["$SLX_CHOOSEN_DISK$i/exists"]}" = "0" ]]; then
+# sgdisk /dev/$SLX_CHOOSEN_DISK -n $j:0:+${PARTTBL["$SLX_CHOOSEN_DISK$i/size"]}G 2> /dev/null > /dev/null
+# while [[ $? -eq 4 ]]; do
+# j=$(($j+1))
+# sgdisk /dev/$SLX_CHOOSEN_DISK -n $j:0:+${PARTTBL["$SLX_CHOOSEN_DISK$i/size"]}G 2> /dev/null > /dev/null
+# done
+# PARTTBL["$SLX_CHOOSEN_DISK$i/exists"]=$SLX_CHOOSEN_DISK$j
+# SIZE=$((${PARTTBL["$SLX_CHOOSEN_DISK$i/size"]}*1024*1024*1024))
+# ID=${PARTTBL["$SLX_CHOOSEN_DISK$i/id"]}
+# MOUNTPOINT=${PARTTBL["$SLX_CHOOSEN_DISK$i/mountpoint"]}
+# dialog_string=$dialog_string$MOUNTPOINT" (/dev/"${PARTTBL["$SLX_CHOOSEN_DISK$i/exists"]}")\n"
+# if [ "${PARTTBL["$SLX_CHOOSEN_DISK$i/id"]}" = "82" ]; then
+# dialog_string=$dialog_string" GUID: 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F\n"
+# elif [ "${PARTTBL["$SLX_CHOOSEN_DISK$i/id"]}" = "83" ]; then
+# dialog_string=$dialog_string" GUID: 0FC63DAF-8483-4772-8E79-3D69D8477DE4\n"
+# else
+# sgdisk /dev/$SLX_CHOOSEN_DISK -t $j:$ID"000000-0000-0000-0000-000000000000" -c $j:$MOUNTPOINT >/dev/null 2>/dev/null
+# dialog_string=$dialog_string" GUID: "$ID"000000-0000-0000-0000-000000000000\n"
+# fi
+# dialog_string=$dialog_string" Size: "$SIZE" Bytes ("${PARTTBL["$SLX_CHOOSEN_DISK$i/size"]}" GB)\n"
+# CREATED=$(($CREATED+1))
+# echo $(( $CREATED*100/($NONEXISTENT_PARTITIONS) )) | dialog --gauge "$dialog_string" 0 0 0
+# fi
+# if [ ${PARTTBL["$SLX_CHOOSEN_DISK$i/bootable"]} -eq 1 ]; then
+# sgdisk /dev/$SLX_CHOOSEN_DISK -A $j:set:2 >/dev/null 2>/dev/null
+# fi
+# fi
+# done
+# fi
+#else
+## finding existent partitions in MS-DOS
+# echo 'MSDOS'
+# for PART in $PARTS; do
+# for (( i = 1; i < $COUNTER; i++ )); do
+# if [ $i -ne 4 ]; then
+# if [ ${PARTTBL["$SLX_CHOOSEN_DISK$i/exists"]} = 0 ]; then
+# sfdisk -d /dev/$SLX_CHOOSEN_DISK 2> /dev/null | grep $PART | tr -s ' ' | cut -d ' ' -f7 | grep ${PARTTBL["$SLX_CHOOSEN_DISK$i/id"]} > /dev/null
+# if [ $? -eq 0 ]; then
+# echo "the partition $PART is the ${PARTTBL["$SLX_CHOOSEN_DISK$i/mountpoint"]} partition."
+# PARTTBL["$SLX_CHOOSEN_DISK$i/exists"]=$PART
+# NEEDED_SPACE=$(($NEEDED_SPACE-${PARTTBL["$SLX_CHOOSEN_DISK$i/size"]}*1024*1024*1024))
+# break
+# fi
+# fi
+# fi
+# done
+# done
+# echo "FREESPACE="$FREESPACE
+# echo "NEEDED_SPACE="$NEEDED_SPACE
+# if [[ $FREESPACE -lt $NEEDED_SPACE ]]; then
+# dialog --msgbox "ERROR: Insufficient free space in disk /dev/$SLX_CHOOSEN_DISK." 6 40
+# exit 1
+# fi
+#fi