Browse Source

Update

master
crims0n 4 years ago
parent
commit
97ac0fb94f
  1. 4
      .gitignore
  2. 2
      linux-live/initramfs/init
  3. 6
      linux-live/initramfs/initramfs_create
  4. BIN
      linux-live/initramfs/minios-modules.tar.xz
  5. BIN
      linux-live/initramfs/static/bash
  6. 343
      linux-live/initramfs/static/cmdline_parser
  7. 523
      linux-live/initramfs/static/minios-configure
  8. 74
      linux-live/livekitlib
  9. 993
      linux-live/minioslib
  10. 9
      linux-live/modules/02-xorg/install
  11. 9
      linux-live/modules/02-xorg/postinstall
  12. 14
      linux-live/modules/03-xfce-desktop/postinstall
  13. 7
      linux-live/modules/04-xfce-apps/install
  14. 8
      linux-live/modules/04-xfce-apps/postinstall
  15. 9
      linux-live/modules/05-firefox/install
  16. 8
      linux-live/modules/05-firefox/postinstall
  17. 2
      minios-modules/etc/bash_completion.d/minios-autoinstall
  18. 57
      minios-modules/etc/minios/config
  19. 617
      minios-modules/usr/lib/minioslib
  20. 23
      modules/06-virtualbox/install
  21. 29
      modules/06-virtualbox/postinstall
  22. 9
      modules/07-vboxextpack/install
  23. 3
      modules/07-vboxextpack/postinstall
  24. BIN
      modules/07-vboxextpack/rootcopy-install/Oracle_VM_VirtualBox_Extension_Pack-6.1.28.vbox-extpack

4
.gitignore

@ -1,3 +1,5 @@
rootfs/
build/
.install_dir
.install_dir
upload_initrfs
linux-live/minioslib copy

2
linux-live/initramfs/init

@ -55,7 +55,7 @@ union_append_bundles "$BUNDLES" "$UNION"
copy_rootcopy_content "$DATA" "$UNION"
# configure
minios_configure "$UNION"
minios_configure "$UNION" "$DATAMNT"
debug_shell
# create fstab
fstab_create "$UNION" "$DATAMNT"

6
linux-live/initramfs/initramfs_create

@ -44,16 +44,17 @@ copy_including_deps() {
}
rm -Rf $INITRAMFS
mkdir -p $INITRAMFS/{bin,dev,etc,lib,lib64,mnt,proc,root,run,sys,tmp,usr,var/log}
mkdir -p $INITRAMFS/{bin,dev,etc,lib,lib64,mnt,opt,proc,root,run,sys,tmp,usr,var/log}
ln -s bin $INITRAMFS/sbin
#cp static/bash $INITRAMFS/bin
cp static/busybox $INITRAMFS/bin
cp static/eject $INITRAMFS/bin
cp static/mount.dynfilefs $INITRAMFS/bin/@mount.dynfilefs
cp static/mount.httpfs2 $INITRAMFS/bin/@mount.httpfs2
cp static/mount.ntfs-3g $INITRAMFS/bin/@mount.ntfs-3g
cp static/blkid $INITRAMFS/bin
cp static/cmdline_parser $INITRAMFS/bin
cp static/minios-configure $INITRAMFS/bin
chmod a+x $INITRAMFS/bin/*
$INITRAMFS/bin/busybox | grep , | grep -v Copyright | tr "," " " | while read LINE; do
@ -196,6 +197,7 @@ ln -s ../init $INITRAMFS/bin/init
cp ../livekitlib $INITRAMFS/lib/
cp ../config $INITRAMFS/lib/
cp ../buildconfig $INITRAMFS/lib/
cp minios-modules.tar.xz $INITRAMFS/opt/
cd $INITRAMFS
find . -print | cpio -o -H newc 2>/dev/null | xz -f --extreme --check=crc32 >$INITRAMFS.img

BIN
linux-live/initramfs/minios-modules.tar.xz

Binary file not shown.

BIN
linux-live/initramfs/static/bash

Binary file not shown.

343
linux-live/initramfs/static/cmdline_parser

@ -1,343 +0,0 @@
#!/bin/bash
#
# Сommand line parsing script.
# Author: crims0n. <http://minios.ru>
#
function read_cmdline() {
for i in $(cat /cmdline); do
case $i in
user_name=*)
USER_NAME="${i#*=}"
shift # past argument=value
;;
user_password=*)
USER_PASSWORD="${i#*=}"
shift # past argument=value
;;
root_password=*)
ROOT_PASSWORD="${i#*=}"
shift # past argument=value
;;
host_name=*)
HOST_NAME="${i#*=}"
shift # past argument=value
;;
default_target=*)
DEFAULT_TARGET="${i#*=}"
shift # past argument=value
;;
ssh)
SSH=true
shift # past argument with no value
;;
cloud)
CLOUD=true
shift # past argument with no value
;;
*)
# unknown option
;;
esac
done
}
function read_config() { # read_config file.cfg var_name1 var_name2
# ref: https://stackoverflow.com/a/20815951
shopt -s extglob # needed the "one of these"-match below
local configfile="${1?No configuration file given}"
local keylist="${@:2}" # positional parameters 2 and following
if [[ ! -f "$configfile" ]]; then
echo >&2 "\"$configfile\" is not a file!"
exit 1
fi
if [[ ! -r "$configfile" ]]; then
echo >&2 "\"$configfile\" is not readable!"
exit 1
fi
keylist="${keylist// /|}" # this will generate a regex 'one of these'
# lhs : "left hand side" : Everything left of the '='
# rhs : "right hand side": Everything right of the '='
#
# "lhs" will hold the name of the key you want to read.
# The value of "rhs" will be assigned to that key.
while IFS='= ' read -r lhs rhs; do
# IF lhs in keylist
# AND rhs not empty
if [[ "$lhs" =~ ^($keylist)$ ]] && [[ -n $rhs ]]; then
rhs="${rhs%\"*}" # Del opening string quotes
rhs="${rhs#\"*}" # Del closing string quotes
rhs="${rhs%\'*}" # Del opening string quotes
rhs="${rhs#\'*}" # Del closing string quotes
eval $lhs=\"$rhs\" # The magic happens here
fi
# tr used as a safeguard against dos line endings
done <<<$(tr -d '\r' <$configfile)
shopt -u extglob # Switching it back off after use
}
$CMDLINE=$(cat /cmdline)
read_cmdline $CMDLINE
if [ -f /run/initramfs/memory/data/minios/minios.conf ]; then
cp /run/initramfs/memory/data/minios/minios.conf /etc/minios.conf
elif [ -f /etc/minios.conf ]; then
cp /etc/minios.conf /run/initramfs/memory/data/minios/minios.conf
fi
if [ -z "$ROOT_PASSWORD" ] || [ "$ROOT_PASSWORD" = "" ]; then
if [ -f /etc/minios.conf ]; then
read_config /etc/minios.conf ROOT_PASSWORD
else
ROOT_PASSWORD="toor"
fi
fi
#echo "Set up password for user 'root'"
echo root:$ROOT_PASSWORD | chpasswd
if [ -f /etc/minios.conf ]; then
sed -i -e "/ROOT_PASSWORD=/s/=.*/=$ROOT_PASSWORD/" /etc/minios.conf
fi
if [ -z "$CLOUD" ] || [ "$CLOUD" = "" ]; then
if [ -f /etc/minios.conf ]; then
read_config /etc/minios.conf CLOUD
else
CLOUD="false"
fi
fi
sed -i -e "/CLOUD=/s/=.*/=$CLOUD/" /etc/minios.conf
if [ "$CLOUD" != "true" ]; then
if [ ! -f /etc/minios.conf ]; then
if [ -z "$USER_NAME" ] || [ "$USER_NAME" = "" ]; then
USER_NAME="live"
fi
if [ "$USER_NAME" != "root" ]; then
#echo "Set up user '$USER_NAME'"
adduser --uid 1000 --gecos '' $USER_NAME --disabled-password
usermod -a -G sudo $USER_NAME
if [ -z "$USER_PASSWORD" ] || [ "$USER_PASSWORD" = "" ]; then
USER_PASSWORD="evil"
fi
#echo "Set up password for user '$USER_NAME'"
echo $USER_NAME:$USER_PASSWORD | chpasswd
fi
else
if [ -z "$USER_NAME" ] || [ "$USER_NAME" = "" ]; then
read_config /etc/minios.conf USER_NAME
fi
if [ -z "$USER_PASSWORD" ] || [ "$USER_PASSWORD" = "" ]; then
read_config /etc/minios.conf USER_PASSWORD
fi
echo $USER_NAME:$USER_PASSWORD | chpasswd
sed -i -e "/USER_PASSWORD=/s/=.*/=$USER_PASSWORD/" /etc/minios.conf
fi
else
USER_NAME="root"
SSH="true"
fi
if [ ! -f /etc/minios.conf ]; then
if [ "$USER_NAME" != "live" ] || [ "$USER_NAME" != "root" ]; then
if [ -d /home/live ]; then
rm -rf /home/live
fi
# create user directories
if [ -d /home/$USER_NAME/$dir ]; then
for dir in Desktop Documents Downloads Music Pictures Public Templates Videos; do
mkdir -p /home/$USER_NAME/$dir
done
chown 1000:1000 /home/$USER_NAME
chown -R 1000:1000 /home/$USER_NAME
fi
fi
fi
if [ -z "$SSH" ] || [ "$SSH" = "" ]; then
if [ -f /etc/minios.conf ]; then
read_config /etc/minios.conf SSH
else
SSH="false"
fi
fi
if [ "$SSH" = "true" ]; then
systemctl enable ssh-keygen
systemctl enable ssh
sed -i 's,#PermitRootLogin prohibit-password,PermitRootLogin yes,g' /etc/ssh/sshd_config
sed -i 's,#PasswordAuthentication yes,PasswordAuthentication yes,g' /etc/ssh/sshd_config
else
systemctl disable ssh-keygen
systemctl disable ssh
SSH="false"
fi
sed -i -e "/SSH=/s/=.*/=$SSH/" /etc/minios.conf
if [ "$USER_NAME" != "root" ]; then
cat <<EOF >/etc/sudoers.d/90-minios
# live user is default user in minios.
# It needs passwordless sudo functionality.
$USER_NAME ALL=(ALL) NOPASSWD:ALL
EOF
fi
if [ "$CLOUD" != "true" ]; then
if [ "$USER_NAME" != "root" ]; then
cat <<EOF >/etc/issue
\l
Thank you for using MiniOS.
Based on Debian GNU/Linux.
Powered by Slax.
:::: :::: ::::::::::: :::: ::: ::::::::::: :::::::: :::::::: 
+:+:+: :+:+:+ :+: :+:+: :+: :+: :+: :+: :+: :+: 
+:+ +:+:+ +:+ +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+ 
+#+ +:+ +#+ +#+ +#+ +:+ +#+ +#+ +#+ +:+ +#++:++#++ 
+#+ +#+ +#+ +#+ +#+#+# +#+ +#+ +#+ +#+ 
#+# #+# #+# #+# #+#+# #+# #+# #+# #+# #+# 
### ### ########### ### #### ########### ######## ######## 
Root login name: root
Password: $ROOT_PASSWORD
User login name: $USER_NAME
Password: $USER_PASSWORD
EOF
else
cat <<EOF >/etc/issue
\l
Thank you for using MiniOS.
Based on Debian GNU/Linux.
Powered by Slax.
:::: :::: ::::::::::: :::: ::: ::::::::::: :::::::: :::::::: 
+:+:+: :+:+:+ :+: :+:+: :+: :+: :+: :+: :+: :+: 
+:+ +:+:+ +:+ +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+ 
+#+ +:+ +#+ +#+ +#+ +:+ +#+ +#+ +#+ +:+ +#++:++#++ 
+#+ +#+ +#+ +#+ +#+#+# +#+ +#+ +#+ +#+ 
#+# #+# #+# #+# #+#+# #+# #+# #+# #+# #+# 
### ### ########### ### #### ########### ######## ######## 
Root login name: root
Password: $ROOT_PASSWORD
EOF
fi
else
cat <<EOF >/etc/issue
\l
Thank you for using MiniOS.
Based on Debian GNU/Linux.
Powered by Slax.
:::: :::: ::::::::::: :::: ::: ::::::::::: :::::::: :::::::: 
+:+:+: :+:+:+ :+: :+:+: :+: :+: :+: :+: :+: :+: 
+:+ +:+:+ +:+ +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+ 
+#+ +:+ +#+ +#+ +#+ +:+ +#+ +#+ +#+ +:+ +#++:++#++ 
+#+ +#+ +#+ +#+ +#+#+# +#+ +#+ +#+ +#+ 
#+# #+# #+# #+# #+#+# #+# #+# #+# #+# #+# 
### ### ########### ### #### ########### ######## ######## 
User login name set by
cloud-init. You must use
your ssh key to login.
Root login name: root
Password: $ROOT_PASSWORD
EOF
fi
if [ -f /usr/lib/systemd/system/xorg.service ]; then
cat <<EOF >/usr/lib/systemd/system/xorg.service
[Unit]
Description=X-Window
ConditionKernelCommandLine=!text
After=systemd-user-sessions.service
[Service]
ExecStart=/bin/su --login -c "/usr/bin/startx -- :0 vt7 -ac -nolisten tcp" $USER_NAME
EOF
fi
if [ -f /etc/default/nodm ]; then
sed -i "s/NODM_USER=live/NODM_USER=$USER_NAME/g" /etc/default/nodm
fi
if [ -f /etc/slim.conf ]; then
sed -i "s/default_user live/default_user $USER_NAME/g" /etc/slim.conf
fi
if [ "$CLOUD" != "true" ]; then
if [ -z "$HOST_NAME" ] || [ "$HOST_NAME" = "" ]; then
if [ -f /etc/minios.conf ]; then
read_config /etc/minios.conf HOST_NAME
else
HOST_NAME="minios"
fi
fi
echo $HOST_NAME >/etc/hostname
if [ -f /etc/minios.conf ]; then
sed -i -e "/HOST_NAME=/s/=.*/=$HOST_NAME/" /etc/minios.conf
fi
fi
if [ -z "$DEFAULT_TARGET" ] || [ "$DEFAULT_TARGET" = "" ]; then
if [ -f /etc/minios.conf ]; then
read_config /etc/minios.conf DEFAULT_TARGET
else
$DEFAULT_TARGET="graphical"
fi
fi
systemctl set-default $DEFAULT_TARGET
if [ -f /etc/minios.conf ]; then
sed -i -e "/DEFAULT_TARGET=/s/=.*/=$DEFAULT_TARGET/" /etc/minios.conf
fi
if [ ! -f /etc/minios.conf ]; then
echo "USER_NAME=$USER_NAME" >/etc/minios.conf
echo "USER_PASSWORD=$USER_PASSWORD" >>/etc/minios.conf
echo "ROOT_PASSWORD=$ROOT_PASSWORD" >>/etc/minios.conf
echo "HOST_NAME=$HOST_NAME" >>/etc/minios.conf
echo "DEFAULT_TARGET=$DEFAULT_TARGET" >>/etc/minios.conf
echo "SSH=$SSH" >>/etc/minios.conf
echo "CLOUD=$CLOUD" >>/etc/minios.conf
fi

523
linux-live/initramfs/static/minios-configure

@ -0,0 +1,523 @@
#!/bin/bash
#
# Сommand line parsing script.
# Author: crims0n. <http://minios.ru>
#
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
function help() {
# if $1 is set, use $1 as headline message in help()
echo -e "root_password - root password."
echo -e "user_name - username. If you specify the username root , then the user profile will not be created, the user_password parameter will be ignored."
echo -e "user_password - user password."
echo -e "host_name - hostname of the system."
echo -e "default_target - target of systemd. For loading GUI - graphical, for loading in command line mode - multi-user, for loading in emergency mode - emergency."
echo -e "ssh - enable ssh."
echo -e "cloud - special mode to run as a cloud-init host."
echo -e ""
echo -e "Example: ${MAGENTA}$0${ENDCOLOUR} root_password=toor user_name=live user_password=evil"
exit 0
}
function allow_root_only() {
if [ $(id -u) -ne 0 ]; then
echo -e "${BOLD}${RED}This script should be run as 'root'!${ENDCOLOUR}"
exit 1
fi
export HOME=/root
export LC_ALL=C
}
function read_cmdline() {
for i in $@; do
case $i in
user_name=*)
USER_NAME="${i#*=}"
shift # past argument=value
;;
user_password=*)
USER_PASSWORD="${i#*=}"
shift # past argument=value
;;
root_password=*)
ROOT_PASSWORD="${i#*=}"
shift # past argument=value
;;
host_name=*)
HOST_NAME="${i#*=}"
shift # past argument=value
;;
default_target=*)
DEFAULT_TARGET="${i#*=}"
shift # past argument=value
;;
ssh)
SSH=true
shift # past argument with no value
;;
cloud)
CLOUD=true
shift # past argument with no value
;;
*)
UNKNOWN=true
# unknown option
;;
esac
done
}
function read_config() { # read_config file.cfg var_name1 var_name2
# ref: https://stackoverflow.com/a/20815951
shopt -s extglob # needed the "one of these"-match below
local configfile="${1?No configuration file given}"
local keylist="${@:2}" # positional parameters 2 and following
if [[ ! -f "$configfile" ]]; then
echo >&2 "\"$configfile\" is not a file!"
exit 1
fi
if [[ ! -r "$configfile" ]]; then
echo >&2 "\"$configfile\" is not readable!"
exit 1
fi
keylist="${keylist// /|}" # this will generate a regex 'one of these'
# lhs : "left hand side" : Everything left of the '='
# rhs : "right hand side": Everything right of the '='
#
# "lhs" will hold the name of the key you want to read.
# The value of "rhs" will be assigned to that key.
while IFS='= ' read -r lhs rhs; do
# IF lhs in keylist
# AND rhs not empty
if [[ "$lhs" =~ ^($keylist)$ ]] && [[ -n $rhs ]]; then
rhs="${rhs%\"*}" # Del opening string quotes
rhs="${rhs#\"*}" # Del closing string quotes
rhs="${rhs%\'*}" # Del opening string quotes
rhs="${rhs#\'*}" # Del closing string quotes
eval $lhs=\"$rhs\" # The magic happens here
fi
# tr used as a safeguard against dos line endings
done <<<$(tr -d '\r' <$configfile)
shopt -u extglob # Switching it back off after use
}
allow_root_only
CURRENT_USER_NAME=$(id -nu 1000 2>/dev/null)
CURRENT_USER_GROUP=$(id -ng 1000 2>/dev/null)
if [ "$SCRIPT_DIR" != "/usr/bin" ]; then
if [ -f /cmdline ]; then
CMDLINE=$(cat /cmdline)
read_cmdline $CMDLINE
fi
if [ -f /livekit.conf ]; then
read_config /livekit.conf LIVEKITNAME
else
LIVEKITNAME="minios"
fi
else
read_cmdline $@
if [[ $# == 0 ]] || [ "$UNKNOWN" = "true" ]; then help; fi
if [ -f /run/initramfs/lib/config ]; then
read_config /run/initramfs/lib/config LIVEKITNAME
else
LIVEKITNAME="minios"
fi
fi
# Set up user 'root'
if [ "$SCRIPT_DIR" != "/usr/bin" ]; then
if [ ! -f /etc/$LIVEKITNAME.conf ]; then
cp -rT /etc/skel /root
chown 0:0 /root
chown -R 0:0 /root
fi
fi
if [ -z "$ROOT_PASSWORD" ]; then
if [ "$SCRIPT_DIR" != "/usr/bin" ]; then
if [ -f /etc/$LIVEKITNAME.conf ]; then
read_config /etc/$LIVEKITNAME.conf ROOT_PASSWORD
if [ -z "$ROOT_PASSWORD" ]; then
ROOT_PASSWORD="toor"
fi
else
ROOT_PASSWORD="toor"
fi
fi
fi
if [ ! -z "$ROOT_PASSWORD" ]; then
echo root:$ROOT_PASSWORD | chpasswd
fi
if [ -z "$CLOUD" ]; then
if [ -f /etc/$LIVEKITNAME.conf ]; then
read_config /etc/$LIVEKITNAME.conf CLOUD
if [ -z "$CLOUD" ]; then
CLOUD="false"
fi
else
CLOUD="false"
fi
fi
sed -i -e "/CLOUD=/s/=.*/=$CLOUD/" /etc/$LIVEKITNAME.conf
if [ "$CLOUD" != "true" ]; then
if [ -z "$USER_NAME" ]; then
if [ "$SCRIPT_DIR" != "/usr/bin" ]; then
if [ -f /etc/$LIVEKITNAME.conf ]; then
read_config /etc/$LIVEKITNAME.conf USER_NAME
fi
if [ -z "$USER_NAME" ]; then
USER_NAME="live"
USER_GROUP="live"
fi
fi
fi
if [ "$USER_NAME" != "root" ]; then
# Set up user
USER_GROUP=$USER_NAME
if [ -z "$CURRENT_USER_NAME" ]; then
adduser --uid 1000 --gecos '' $USER_NAME --disabled-password
usermod -a -G sudo $USER_NAME
elif [ "$USER_NAME" != "$CURRENT_USER_NAME" ]; then
if [ "$SCRIPT_DIR" = "/usr/bin" ]; then
if [[ ! $(ps -u $CURRENT_USER_NAME) ]]; then
usermod -l $USER_NAME $CURRENT_USER_NAME
usermod -m -d /home/$USER_NAME $USER_NAME
groupmod -n $USER_GROUP $CURRENT_USER_GROUP
else
echo "Processes are running under the $CURRENT_USER_NAME. Username will be changed after system reboot."
USER_NAME_CHANGE_PENDING="true"
fi
else
usermod -l $USER_NAME $CURRENT_USER_NAME
usermod -m -d /home/$USER_NAME $USER_NAME
groupmod -n $USER_GROUP $CURRENT_USER_GROUP
fi
fi
fi
if [ -z "$USER_PASSWORD" ]; then
if [ "$SCRIPT_DIR" != "/usr/bin" ]; then
if [ "$USER_NAME" != "$CURRENT_USER_NAME" ]; then
if [ -f /etc/$LIVEKITNAME.conf ]; then
read_config /etc/$LIVEKITNAME.conf USER_PASSWORD
fi
if [ -z "$USER_PASSWORD" ]; then
USER_PASSWORD="evil"
fi
fi
fi
fi
if [ ! -z "$USER_PASSWORD" ]; then
# Set up password for user
if [ "$USER_NAME_CHANGE_PENDING" = "true" ]; then
echo $CURRENT_USER_NAME:$USER_PASSWORD | chpasswd
else
if [ -z "$USER_NAME" ]; then
if [ ! -z "$CURRENT_USER_NAME" ]; then
echo $CURRENT_USER_NAME:$USER_PASSWORD | chpasswd
else
echo "Username not specified"
fi
else
echo $USER_NAME:$USER_PASSWORD | chpasswd
fi
fi
fi
else
USER_NAME="root"
SSH="true"
DEFAULT_TARGET="multi-user"
fi
if [ ! -f /etc/$LIVEKITNAME.conf ]; then
if [ "$USER_NAME" != "root" ]; then
if [ ! -z $USER_NAME ]; then
if [ -z $CURRENT_USER_NAME ]; then
# create user directories
if [ -d /home/$USER_NAME/$dir ]; then
for dir in Desktop Documents Downloads Music Pictures Public Templates Videos; do
mkdir -p /home/$USER_NAME/$dir
done
UID=$(id -u $USER_NAME)
GID=$(id -g $USER_NAME)
chown $USER_NAME:$USER_NAME /home/$USER_NAME
chown -R $USER_NAME:$USER_NAME /home/$USER_NAME
fi
fi
fi
fi
fi
if [ -z "$SSH" ]; then
if [ "$SCRIPT_DIR" != "/usr/bin" ]; then
if [ -f /etc/$LIVEKITNAME.conf ]; then
read_config /etc/$LIVEKITNAME.conf SSH
if [ -z "$SSH" ]; then
SSH="false"
fi
else
SSH="false"
fi
fi
fi
if [ ! -z "$SSH" ]; then
if [ "$SSH" = "true" ]; then
systemctl enable ssh-keygen
systemctl enable ssh
sed -i 's,#PermitRootLogin prohibit-password,PermitRootLogin yes,g' /etc/ssh/sshd_config
sed -i 's,#PasswordAuthentication yes,PasswordAuthentication yes,g' /etc/ssh/sshd_config
else
systemctl disable ssh-keygen
systemctl disable ssh
SSH="false"
fi
fi
if [ ! -z "$USER_NAME" ]; then
if [ "$USER_NAME" != "root" ]; then
cat <<EOF >/etc/sudoers.d/90-minios
# live user is default user in minios.
# It needs passwordless sudo functionality.
$USER_NAME ALL=(ALL) NOPASSWD:ALL
EOF
fi
fi
if [ "$CLOUD" != "true" ]; then
if [ ! -z "$USER_NAME" ]; then
if [ "$USER_NAME" != "root" ]; then
cat <<EOF >/etc/issue
\l
Thank you for using MiniOS.
Based on Debian GNU/Linux.
Powered by Slax.
:::: :::: ::::::::::: :::: ::: ::::::::::: :::::::: :::::::: 
+:+:+: :+:+:+ :+: :+:+: :+: :+: :+: :+: :+: :+: 
+:+ +:+:+ +:+ +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+ 
+#+ +:+ +#+ +#+ +#+ +:+ +#+ +#+ +#+ +:+ +#++:++#++ 
+#+ +#+ +#+ +#+ +#+#+# +#+ +#+ +#+ +#+ 
#+# #+# #+# #+# #+#+# #+# #+# #+# #+# #+# 
### ### ########### ### #### ########### ######## ######## 
Root login name: root
Password: $ROOT_PASSWORD
User login name: $USER_NAME
Password: $USER_PASSWORD
EOF
else
cat <<EOF >/etc/issue
\l
Thank you for using MiniOS.
Based on Debian GNU/Linux.
Powered by Slax.
:::: :::: ::::::::::: :::: ::: ::::::::::: :::::::: :::::::: 
+:+:+: :+:+:+ :+: :+:+: :+: :+: :+: :+: :+: :+: 
+:+ +:+:+ +:+ +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+ 
+#+ +:+ +#+ +#+ +#+ +:+ +#+ +#+ +#+ +:+ +#++:++#++ 
+#+ +#+ +#+ +#+ +#+#+# +#+ +#+ +#+ +#+ 
#+# #+# #+# #+# #+#+# #+# #+# #+# #+# #+# 
### ### ########### ### #### ########### ######## ######## 
Root login name: root
Password: $ROOT_PASSWORD
EOF
fi
fi
else
cat <<EOF >/etc/issue
\l
Thank you for using MiniOS.
Based on Debian GNU/Linux.
Powered by Slax.
:::: :::: ::::::::::: :::: ::: ::::::::::: :::::::: :::::::: 
+:+:+: :+:+:+ :+: :+:+: :+: :+: :+: :+: :+: :+: 
+:+ +:+:+ +:+ +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+ 
+#+ +:+ +#+ +#+ +#+ +:+ +#+ +#+ +#+ +:+ +#++:++#++ 
+#+ +#+ +#+ +#+ +#+#+# +#+ +#+ +#+ +#+ 
#+# #+# #+# #+# #+#+# #+# #+# #+# #+# #+# 
### ### ########### ### #### ########### ######## ######## 
User login name set by
cloud-init. You must use
your ssh key to login.
Root login name: root
Password: $ROOT_PASSWORD
EOF
fi
cat <<EOF >/usr/lib/systemd/system/minios-configure.service
[Unit]
Description=MiniOS config file updater
[Service]
Type=oneshot
RemainAfterExit=true
ExecStop=-/bin/sh -c "if [ -f /run/initramfs/memory/data/$LIVEKITNAME/$LIVEKITNAME.conf ]; then if [ /etc/$LIVEKITNAME.conf -nt /run/initramfs/memory/data/$LIVEKITNAME/$LIVEKITNAME.conf ]; then cp -fp /etc/$LIVEKITNAME.conf /run/initramfs/memory/data/$LIVEKITNAME/$LIVEKITNAME.conf; fi; fi"
[Install]
WantedBy=multi-user.target
EOF
if [ ! -z "$USER_NAME" ]; then
if [ -f /usr/lib/systemd/system/xorg.service ]; then
cat <<EOF >/usr/lib/systemd/system/xorg.service
[Unit]
Description=X-Window
ConditionKernelCommandLine=!text
After=systemd-user-sessions.service
[Service]
ExecStart=/bin/su --login -c "/usr/bin/startx -- :0 vt7 -ac -nolisten tcp" $USER_NAME
EOF
fi
if [ -f /etc/default/nodm ]; then
sed -i "s/NODM_USER=live/NODM_USER=$USER_NAME/g" /etc/default/nodm
fi
if [ -f /etc/slim.conf ]; then
sed -i "s/default_user live/default_user $USER_NAME/g" /etc/slim.conf
fi
fi
if [ "$CLOUD" != "true" ]; then
if [ -z "$HOST_NAME" ]; then
if [ "$SCRIPT_DIR" != "/usr/bin" ]; then
if [ -f /etc/$LIVEKITNAME.conf ]; then
read_config /etc/$LIVEKITNAME.conf HOST_NAME
if [ -z "$HOST_NAME" ]; then
HOST_NAME="minios"
fi
else
HOST_NAME="minios"
fi
fi
fi
if [ ! -z "$HOST_NAME" ]; then
echo $HOST_NAME >/etc/hostname
cat <<EOF >/etc/hosts
127.0.0.1 localhost $HOST_NAME
::1 localhost ip6-localhost ip6-loopback $HOST_NAME
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF
fi
fi
if [ -z "$DEFAULT_TARGET" ]; then
if [ "$SCRIPT_DIR" != "/usr/bin" ]; then
if [ -f /etc/$LIVEKITNAME.conf ]; then
read_config /etc/$LIVEKITNAME.conf DEFAULT_TARGET
if [ -z "$DEFAULT_TARGET" ]; then
DEFAULT_TARGET="graphical"
fi
else
DEFAULT_TARGET="graphical"
fi
fi
fi
if [ ! -z "$DEFAULT_TARGET" ]; then
systemctl set-default $DEFAULT_TARGET
fi
if [ -f /minios-modules.tar.xz ]; then
tar -xJf /minios-modules.tar.xz -C /
rm /minios-modules.tar.xz
fi
systemctl enable minios-configure
if [ "$SCRIPT_DIR" != "/usr/bin" ]; then
cat <<EOF >/etc/$LIVEKITNAME.conf
# =================================================================
# Be careful. If you are using persistent mode, do not change the
# DEFAULT_TARGET and CLOUD variables, it may break your system.
# Please do not change the username, password and root password by
# system tools, they will be automatically replaced with the ones
# specified here during system reboot/shutdown. If you delete the
# configuration files ($LIVEKITNAME.conf), the username, password,
# password of the root user will be replaced with the default ones.
# =================================================================
USER_NAME=$USER_NAME
USER_PASSWORD=$USER_PASSWORD
ROOT_PASSWORD=$ROOT_PASSWORD
HOST_NAME=$HOST_NAME
DEFAULT_TARGET=$DEFAULT_TARGET
SSH=$SSH
CLOUD=$CLOUD
EOF
else
if [ ! -z "$USER_NAME" ]; then
sed -i -e "/USER_NAME=/s/=.*/=$USER_NAME/" /etc/$LIVEKITNAME.conf
fi
if [ ! -z "$USER_PASSWORD" ]; then
sed -i -e "/USER_PASSWORD=/s/=.*/=$USER_PASSWORD/" /etc/$LIVEKITNAME.conf
fi
if [ ! -z "$ROOT_PASSWORD" ]; then
sed -i -e "/ROOT_PASSWORD=/s/=.*/=$ROOT_PASSWORD/" /etc/$LIVEKITNAME.conf
fi
if [ ! -z "$HOST_NAME" ]; then
sed -i -e "/HOST_NAME=/s/=.*/=$HOST_NAME/" /etc/$LIVEKITNAME.conf
fi
if [ ! -z "$DEFAULT_TARGET" ]; then
sed -i -e "/DEFAULT_TARGET=/s/=.*/=$DEFAULT_TARGET/" /etc/$LIVEKITNAME.conf
fi
if [ ! -z "$SSH" ]; then
sed -i -e "/SSH=/s/=.*/=$SSH/" /etc/$LIVEKITNAME.conf
fi
if [ ! -z "$CLOUD" ]; then
sed -i -e "/CLOUD=/s/=.*/=$CLOUD/" /etc/$LIVEKITNAME.conf
fi
fi

74
linux-live/livekitlib

@ -83,6 +83,14 @@ cmdline_value() {
cat /proc/cmdline | egrep -o "(^|[[:space:]])$1=[^[:space:]]+" | tr -d " " | cut -d "=" -f 2- | tail -n 1
}
# get value of config parameter $2
# $1 = config file name
# $2 = parameter to search for
#
config_value() {
cat $1 | egrep -o "(^|[[:space:]])$2=[^[:space:]]+" | tr -d " " | cut -d "=" -f 2- | tail -n 1
}
# test if the script is started by root user. If not, exit
#
allow_only_root() {
@ -575,7 +583,7 @@ check_data_found() {
persistent_changes() {
debug_log "persistent_changes" "$*"
local CHANGES T1 T2 EXISTS
local CHANGES T1 T2 EXISTS CHANGES_SIZE
CHANGES="$1/$(basename "$2")"
T1="$CHANGES/.empty"
@ -611,19 +619,27 @@ persistent_changes() {
return
fi
if [ -e "$CHANGES/changes.dat" ]; then
echo "* Restoring persistent changes"
EXISTS="true"
if grep -vq remove_changes /proc/cmdline; then
if [ -e "$CHANGES/changes.dat" ]; then
echo "* Restoring persistent changes"
EXISTS="true"
else
echo "* Creating new persistent changes"
EXISTS=""
fi
else
if [ -f "$CHANGES/changes.dat" ]; then
rm -f "$CHANGES/changes.dat"
fi
echo "* Creating new persistent changes"
EXISTS=""
fi
PERCH_SIZE=$(cmdline_value perch_size)
if [ ! "$PERCH_SIZE" ]; then
CHANGES_SIZE=$(cmdline_value changes_size)
if [ ! "$CHANGES_SIZE" ]; then
@mount.dynfilefs "$CHANGES/changes.dat" 4000 "$2"
else
@mount.dynfilefs "$CHANGES/changes.dat" $PERCH_SIZE "$2"
@mount.dynfilefs "$CHANGES/changes.dat" $CHANGES_SIZE "$2"
fi
if [ ! "$EXISTS" ]; then
mke2fs -F "$2/loop.fs" >/dev/null 2>&1
@ -784,13 +800,51 @@ fstab_create() {
minios_configure() {
debug_log "minios_configure" "$*"
cp /bin/cmdline_parser $1/
local WRITABLE
cp /bin/minios-configure $1/
cat /proc/cmdline >$1/cmdline
chroot $1 /bin/bash -c "/cmdline_parser" >/dev/null 2>&1
touch "$2/$LIVEKITNAME/.empty" 2>/dev/null && rm -f "$2/$LIVEKITNAME/.empty" 2>/dev/null
if [ $? -ne 0 ]; then
WRITABLE="false"
#echo "* Directory $2/$LIVEKITNAME not writable"
else
WRITABLE="true"
if [ -d $2/$LIVEKITNAME ]; then
if [ -f $2/$LIVEKITNAME/$LIVEKITNAME.conf ] && [ -f $1/etc/$LIVEKITNAME.conf ]; then
if [ "$2/$LIVEKITNAME/$LIVEKITNAME.conf" -nt "$1/etc/$LIVEKITNAME.conf" ]; then
cp -fp $2/$LIVEKITNAME/$LIVEKITNAME.conf $1/etc/$LIVEKITNAME.conf
elif [ "$2/$LIVEKITNAME/$LIVEKITNAME.conf" -ot "$1/etc/$LIVEKITNAME.conf" ]; then
cp -fp $1/etc/$LIVEKITNAME.conf $2/$LIVEKITNAME/$LIVEKITNAME.conf
fi
elif [ -f $2/$LIVEKITNAME/$LIVEKITNAME.conf ]; then
cp -fp $2/$LIVEKITNAME/$LIVEKITNAME.conf $1/etc/$LIVEKITNAME.conf
elif [ -f $1/etc/$LIVEKITNAME.conf ]; then
cp -fp $1/etc/$LIVEKITNAME.conf $2/$LIVEKITNAME/$LIVEKITNAME.conf
fi
fi
fi
echo "LIVEKITNAME=$LIVEKITNAME" >$1/livekit.conf
if grep -q minios_modules /proc/cmdline; then
cp /opt/minios-modules.tar.xz $1/minios-modules.tar.xz
fi
chroot $1 /bin/bash -c "/minios-configure" >/dev/null 2>&1
if [ "$WRITABLE" = "true" ]; then
if [ -f $1/etc/$LIVEKITNAME.conf ]; then
cp -fp $1/etc/$LIVEKITNAME.conf $2/$LIVEKITNAME/$LIVEKITNAME.conf
fi
fi
rm -f $1/cmdline
rm -f $1/cmdline_parser
mv -f $1/minios-configure $1/usr/bin/minios-configure
chmod 755 $1/usr/bin/minios-configure
rm -f $1/livekit.conf
}
# Change root and execute init

993
linux-live/minioslib

File diff suppressed because it is too large

9
linux-live/modules/02-xorg/install

@ -24,11 +24,4 @@ After=systemd-user-sessions.service
[Service]
ExecStart=/bin/su --login -c "/usr/bin/startx -- :0 vt7 -ac -nolisten tcp" $USER_NAME
EOF
cp -rT /etc/skel /home/$USER_NAME
cp -rT /etc/skel /root
chown 1000:1000 /home/$USER_NAME
chown -R 1000:1000 /home/$USER_NAME
chown 0:0 /root
chown -R 0:0 /root
EOF

9
linux-live/modules/02-xorg/postinstall

@ -1,12 +1,5 @@
#!/bin/bash
cp -rT /etc/skel /home/$USER_NAME
cp -rT /etc/skel /root
chown 1000:1000 /home/$USER_NAME
chown -R 1000:1000 /home/$USER_NAME
chown 0:0 /root
chown -R 0:0 /root
# Set setuid bit on xorg binary, so it can be started by guest user
chmod u+s /usr/lib/xorg/Xorg
@ -26,4 +19,6 @@ dpkg -x x11-xserver-utils*.deb /tmp/x11utils >>$OUTPUT 2>&1
cd /tmp/x11utils
cp -aR * / >>$OUTPUT 2>&1
rm -Rf /usr/share/icons/hicolor/256x256 >>$OUTPUT 2>&1
update-alternatives --set x-terminal-emulator /usr/bin/xterm >>$OUTPUT 2>&1

14
linux-live/modules/03-xfce-desktop/postinstall

@ -1,18 +1,5 @@
#!/bin/bash
# create user directories
for dir in Desktop Documents Downloads Music Pictures Public Templates Videos; do
mkdir -p /home/$USER_NAME/$dir >>$OUTPUT 2>&1
mkdir -p /root/$dir >>$OUTPUT 2>&1
done
cp -rT /etc/skel /home/$USER_NAME
cp -rT /etc/skel /root
chown 1000:1000 /home/$USER_NAME
chown -R 1000:1000 /home/$USER_NAME
chown 0:0 /root
chown -R 0:0 /root
rm -f /usr/share/backgrounds/xfce/*
ln -s /usr/share/backgrounds/MiniOS-wallpaper.svg /usr/share/backgrounds/xfce/xfce-verticals.png
ln -s /usr/share/backgrounds/MiniOS-wallpaper.svg /usr/share/backgrounds/xfce/xfce-teal.jpg
@ -193,6 +180,7 @@ Categories=System;Utility;
EOF
fi
rm -Rf /usr/share/icons/hicolor/256x256 >>$OUTPUT 2>&1
rm -Rf /usr/share/icons/gnome/256x256 >>$OUTPUT 2>&1
update-alternatives --set x-terminal-emulator /usr/bin/xterm >>$OUTPUT 2>&1

7
linux-live/modules/04-xfce-apps/install

@ -43,10 +43,3 @@ WebBrowser=firefox
EOF
fi
cp -rT /etc/skel /home/$USER_NAME
cp -rT /etc/skel /root
chown 1000:1000 /home/$USER_NAME
chown -R 1000:1000 /home/$USER_NAME
chown 0:0 /root
chown -R 0:0 /root

8
linux-live/modules/04-xfce-apps/postinstall

@ -1,16 +1,10 @@
#!/bin/bash
cp -rT /etc/skel /home/$USER_NAME
cp -rT /etc/skel /root
chown 1000:1000 /home/$USER_NAME
chown -R 1000:1000 /home/$USER_NAME
chown 0:0 /root
chown -R 0:0 /root
if [ $PACKAGE_VARIANT = "minimal" ]; then
sed -i 's,create=xarchiver --add-to,create=xarchiver --compress,g' /usr/share/libfm/archivers.list
fi
rm -Rf /usr/share/icons/hicolor/256x256 >>$OUTPUT 2>&1
rm -Rf /usr/share/icons/gnome/256x256 >>$OUTPUT 2>&1
rm -Rf /usr/share/icons/Adwaita/256x256 >>$OUTPUT 2>&1
rm -Rf /usr/share/icons/Adwaita/512x512 >>$OUTPUT 2>&1

9
linux-live/modules/05-firefox/install

@ -31,11 +31,4 @@ FileManager=Thunar
WebBrowser=firefox
EOF
fi
cp -rT /etc/skel /home/$USER_NAME
cp -rT /etc/skel /root
chown 1000:1000 /home/$USER_NAME
chown -R 1000:1000 /home/$USER_NAME
chown 0:0 /root
chown -R 0:0 /root
fi

8
linux-live/modules/05-firefox/postinstall

@ -1,10 +1,4 @@
#!/bin/bash
cp -rT /etc/skel /home/$USER_NAME
cp -rT /etc/skel /root
chown 1000:1000 /home/$USER_NAME
chown -R 1000:1000 /home/$USER_NAME
chown 0:0 /root
chown -R 0:0 /root
rm -Rf /usr/share/icons/hicolor/256x256 >>$OUTPUT 2>&1
rm -Rf /usr/share/icons/gnome/256x256 >>$OUTPUT 2>&1

2
minios-modules/etc/bash_completion.d/minios-autoinstall

@ -1,2 +1,2 @@
#/usr/bin/env bash
complete -W "build_modules repack_system" minios-install
complete -W "build_modules repack_system" minios-autoinstall

57
minios-modules/etc/minios/config

@ -1,17 +1,7 @@
#!/bin/bash
# This is a config file for MiniOS-Live build script and Linux Live Kit boot script.
# You shouldn't need to change anything expect LIVEKITNAME PACKAGE_VARIANT OUTPUT COMP_TYPE
# You shouldn't need to change anything expect PACKAGE_VARIANT OUTPUT COMP_TYPE
# Live Kit Name. Defaults to 'linux';
# This will be the name of the directory created on your CD/USB, which
# will contain everything including boot files and such.
# For example, Slax changes it to 'slax'
# Must not contain any spaces.
# If you change it, you must run ./tools/isolinux.bin.update script
# in order to update isolinux.bin for CD booting.
# If you do not need booting from CD (eg you're booting only from USB)
# then you can ignore recompiling isolinux.bin, just rename LIVEKITNAME
# and you're done.
LIVEKITNAME="minios"
SYSTEMNAME="MiniOS"
@ -27,8 +17,8 @@ PACKAGE_VARIANT="standard"
LIVE_TYPE="livekit"
# default is output to log. you can use OUTPUT="/dev/stdout" if you want to route events to standard output.
#OUTPUT="/dev/stdout"
OUTPUT="/dev/null"
OUTPUT="/dev/stdout"
#OUTPUT="/dev/null"
DEBIAN_FRONTEND_TYPE="noninteractive"
@ -36,44 +26,9 @@ APT_CMD="apt-get"
APT_OPTIONS="-y"
APT_OPTIONS2="--no-install-recommends"
UNION_BUILD_TYPE="overlayfs"
# Compression method used for the system and modules.
COMP_TYPE="lz4"
# Kernel file, will be copied to your Live Kit
# Your kernel must support aufs and squashfs. Debian Jessie's kernel is ready
# out of the box.
VMLINUZ="/vmlinuz"
# Kernel version. Change it to "3.2.28" for example, if you are building
# Live Kit with a different kernel than the one you are actually running
if [ -f /usr/bin/dpkg-query ] 2>/dev/null; then
KERNEL=$(dpkg-query -W -f='${binary:Package}\n' linux-image-* | head -n 1 | sed 's/linux-image-//')
else
KERNEL=$(uname -r)
fi
# List of directories for root filesystem
# No subdirectories are allowed, no slashes,
# so You can't use /var/tmp here for example
# Exclude directories like proc sys tmp
MKMOD="bin etc home lib lib64 opt root sbin srv usr var"
BEXT="sb"
# If you require network support in initrd, for example to boot over
# PXE or to load data using 'from' boot parameter from a http server,
# you will need network modules included in your initrd.
# This is disabled by default since most people won't need it.
# To enable, set to true
NETWORK=true
# Temporary directory to store livekit filesystem
LIVEKITDATA=/tmp/$LIVEKITNAME-data-$$
# Bundle extension, for example 'sb' for .sb extension
BEXT=sb
# Directory with kernel .ko modules, can be different in some distros
LMK="lib/modules/$KERNEL"
# Compression method used for the system and modules.
COMP_TYPE="xz"

617
minios-modules/usr/lib/minioslib

@ -13,10 +13,10 @@
function common_variables() {
if [ $DISTRIBUTION_ARCH = "amd64" ]; then
KERNEL_ARCH="amd64"
PACKAGE_VARIANT="standard"
#PACKAGE_VARIANT="standard"
elif [ $DISTRIBUTION_ARCH = "i386" ]; then
KERNEL_ARCH="686-pae"
PACKAGE_VARIANT="minimal"
#PACKAGE_VARIANT="minimal"
elif [ $DISTRIBUTION_ARCH = "arm64" ]; then
KERNEL_ARCH="arm64"
fi
@ -66,58 +66,67 @@ function console_colours() {
# =================================================================
function help() {
# if $1 is set, use $1 as headline message in help()
if grep 'LANG="ru_RU.UTF-8"' /etc/default/locale >>$OUTPUT; then
if [ -z ${1+x} ]; then
echo -e "${LIGHTYELLOW}Этот скрипт собирает загружаемый ISO образ $SYSTEMNAME.${ENDCOLOUR}"
if [ -f /etc/default/locale ]; then
if grep -q 'LANG="ru_RU.UTF-8"' /etc/default/locale >>$OUTPUT; then
if [ -z ${1+x} ]; then
echo -e "${LIGHTYELLOW}Этот скрипт собирает модули для $SYSTEMNAME.${ENDCOLOUR}"
echo -e
else
echo -e $1
echo
fi
echo -e "Поддерживаемые команды : ${CYAN}${CMD[*]}${ENDCOLOUR}"
echo -e
echo -e "Синтаксис: ${MAGENTA}$0${ENDCOLOUR} [start_cmd] [-] [end_cmd]"
if [ -L /usr/bin/$LIVEKITNAME-install ] && [ "$0" != "/usr/bin/$LIVEKITNAME-install" ]; then
echo -e "\t${CYAN}$LIVEKITNAME-install${ENDCOLOUR} [start_cmd] [-] [end_cmd]"
fi
echo -e "\tзапуск от start_cmd до end_cmd"
echo -e "\tесли start_cmd опущен, выполняются все команды, начиная с первой"
echo -e "\tесли end_cmd опущен, выполняются все команды до последней"
echo -e "\tвведите одну команду, чтобы запустить определенную команду"
echo -e "\tвведите '-' как единственный аргумент для запуска всех команд"
echo -e "\t"
echo -e "\tСкрипты установки должны находиться в папке с именем будущего модуля."
echo -e "\tНапример, чтобы собрать модуль с именем 06-vscode, скрипты сборки"
echo -e "\tдолжны находиться по следующему пути: ${LIGHTYELLOW}$CURRENT_DIR/modules/06-vscode${ENDCOLOUR}"
echo -e "\tПримеры:"
echo -e "\t${LIGHTYELLOW}$0 build_modules${ENDCOLOUR} сборка модулей"
echo -e "\t${LIGHTYELLOW}$0 repack_system${ENDCOLOUR} перепаковка системы с типом сжатия, указанным"
echo -e "\tв /etc/$LIVEKITNAME/config в переменной COMP_TYPE"
echo -e "\t${LIGHTYELLOW}$0 -${ENDCOLOUR} эта команда запустит обе функции поочерёдно"
exit 0
else
echo -e $1
echo
fi
echo -e "Поддерживаемые команды : ${CYAN}${CMD[*]}${ENDCOLOUR}"
echo -e
echo -e "Синтаксис: ${MAGENTA}$0${ENDCOLOUR} [start_cmd] [-] [end_cmd]"
if [ -L /usr/bin/$LIVEKITNAME-install ] && [ "$0" != "/usr/bin/$LIVEKITNAME-install" ]; then
echo -e "\t${CYAN}$LIVEKITNAME-install${ENDCOLOUR} [start_cmd] [-] [end_cmd]"
fi
echo -e "\tзапуск от start_cmd до end_cmd"
echo -e "\tесли start_cmd опущен, выполняются все команды, начиная с первой"
echo -e "\tесли end_cmd опущен, выполняются все команды до последней"
echo -e "\tвведите одну команду, чтобы запустить определенную команду"
echo -e "\tвведите '-' как единственный аргумент для запуска всех команд"
echo -e "\t"
echo -e "\tПримеры:${LIGHTYELLOW}$0 build_bootstrap - build_chroot${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 - build_chroot${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 build_bootstrap -${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 build_iso${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 -${ENDCOLOUR}"
exit 0
else
if [ -z ${1+x} ]; then
echo -e "${LIGHTYELLOW}This script builds bootable $SYSTEMNAME ISO image.${ENDCOLOUR}"
if [ -z ${1+x} ]; then
echo -e "${LIGHTYELLOW}This script builds modules for $SYSTEMNAME.${ENDCOLOUR}"
echo -e
else
echo -e $1
echo
fi
echo -e "Supported commands : ${CYAN}${CMD[*]}${ENDCOLOUR}"
echo -e
else
echo -e $1
echo
fi
echo -e "Supported commands : ${CYAN}${CMD[*]}${ENDCOLOUR}"
echo -e
echo -e "Syntax: ${MAGENTA}$0${ENDCOLOUR} [start_cmd] [-] [end_cmd]"
if [ -L /usr/bin/$LIVEKITNAME-install ] && [ "$0" != "/usr/bin/$LIVEKITNAME-install" ]; then
echo -e "\t${CYAN}$LIVEKITNAME-install${ENDCOLOUR} [start_cmd] [-] [end_cmd]"
echo -e "Syntax: ${MAGENTA}$0${ENDCOLOUR} [start_cmd] [-] [end_cmd]"
if [ -L /usr/bin/$LIVEKITNAME-install ] && [ "$0" != "/usr/bin/$LIVEKITNAME-install" ]; then
echo -e "\t${CYAN}$LIVEKITNAME-install${ENDCOLOUR} [start_cmd] [-] [end_cmd]"
fi
echo -e "\trun from start_cmd to end_cmd"
echo -e "\tif start_cmd is omitted, start from first command"
echo -e "\tif end_cmd is omitted, end with last command"
echo -e "\tenter single cmd to run the specific command"
echo -e "\tenter '-' as only argument to run all commands"
echo -e "\t"
echo -e "\tThe installation scripts must be in the folder with the"
echo -e "\tname of the future module. For example, to build a module"
echo -e "\tnamed 06-vscode, build scripts should be in the following"
echo -e "\tpath: ${LIGHTYELLOW}$CURRENT_DIR/modules/06-vscode${ENDCOLOUR}"
echo -e "\tExamples:"
echo -e "\t${LIGHTYELLOW}$0 build_modules ${ENDCOLOUR} build modules"
echo -e "\t${LIGHTYELLOW}$0 repack_system ${ENDCOLOUR} repack the system with the"
echo -e "\tcompression type specified by /etc/$LIVEKITNAME/config in COMP_TYPE variable"
echo -e "\t${LIGHTYELLOW}$0 - ${ENDCOLOUR} this command will run both functions alternately"
exit 0
fi
echo -e "\trun from start_cmd to end_cmd"
echo -e "\tif start_cmd is omitted, start from first command"
echo -e "\tif end_cmd is omitted, end with last command"
echo -e "\tenter single cmd to run the specific command"
echo -e "\tenter '-' as only argument to run all commands"
echo -e "\t"
echo -e "\tExamples:${LIGHTYELLOW}$0 build_bootstrap - build_chroot${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 - build_chroot${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 build_bootstrap -${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 build_iso${ENDCOLOUR}"
echo -e "\t\t${LIGHTYELLOW}$0 -${ENDCOLOUR}"
exit 0
fi
}
@ -227,6 +236,134 @@ function check_is_in_chroot() {
fi
}
# Unzip gzipped files (man pages), so LZMA can compress 2times better.
# First we fix symlinks, then uncompress files
# $1 = search directory
uncompress_files() {
local LINK LINE
find "$1" -type l -name "*.gz" | while read LINE; do
LINK="$(readlink "$LINE" | sed -r 's/.gz$//')"
FILE="$(echo "$LINE" | sed -r 's/.gz$//')"
ln -sfn "$LINK" "$FILE"
rm -f "$LINE"
done
find "$1" -type f -name "*.gz" | xargs -r gunzip
}
# remove broken links
# $1 = search directory
remove_broken_links() {
find "$1" -type l -exec test ! -e {} \; -print | xargs rm -vf
}
function add_chroot_configuration_files() {
cat <<EOF >$1/$LIVEKITNAME.conf
OUTPUT=$OUTPUT
LOGPATH=$LOGPATH
BUILD_TEST_ISO=$BUILD_TEST_ISO
CREATE_BACKUP=$CREATE_BACKUP
DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE
APT_CMD=$APT_CMD
APT_OPTIONS=$APT_OPTIONS
LIVE_TYPE=$LIVE_TYPE
DISTRIBUTION=$DISTRIBUTION
DISTRIBUTION_TYPE=$DISTRIBUTION_TYPE
PACKAGE_VARIANT=$PACKAGE_VARIANT
COMP_TYPE=$COMP_TYPE
KERNEL_ARCH=$KERNEL_ARCH
USER_NAME=$USER_NAME
EOF
cat <<'EOF' >$1/functions
#!/bin/bash
# =================================================================
# beautiful console
# красивая консоль
# =================================================================
function console_colours() {
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
BLUE="\e[34m"
MAGENTA="\e[35m"
CYAN="\e[36m"
LIGHTGRAY="\e[37m"
DARKGRAY="\e[90m"
LIGHTRED="\e[91m"
LIGHTGREEN="\e[92m"
LIGHTYELLOW="\e[93m"
LIGHTBLUE="\e[94m"
LIGHTMAGENTA="\e[95m"
LIGHTCYAN="\e[96m"
BOLD="\e[1m"
DIM="\e[2m"
UNDERLINED="\e[4m"
BLINK="\e[5m"
REVERSE="\e[7m"
HIDDEN="\e[8m"
ENDCOLOUR="\e[0m"
}
# =================================================================
# reading configuration file
# чтение конфигурационного файла
# =================================================================
function read_config() { # read_config file.cfg var_name1 var_name2
# ref: https://stackoverflow.com/a/20815951
shopt -s extglob # needed the "one of these"-match below
local configfile="${1?No configuration file given}"
local keylist="${@:2}" # positional parameters 2 and following
if [[ ! -f "$configfile" ]]; then
echo >&2 "\"$configfile\" is not a file!"
exit 1
fi
if [[ ! -r "$configfile" ]]; then
echo >&2 "\"$configfile\" is not readable!"
exit 1
fi
keylist="${keylist// /|}" # this will generate a regex 'one of these'
# lhs : "left hand side" : Everything left of the '='
# rhs : "right hand side": Everything right of the '='
#
# "lhs" will hold the name of the key you want to read.
# The value of "rhs" will be assigned to that key.
while IFS='= ' read -r lhs rhs; do
# IF lhs in keylist
# AND rhs not empty
if [[ "$lhs" =~ ^($keylist)$ ]] && [[ -n $rhs ]]; then
rhs="${rhs%\"*}" # Del opening string quotes
rhs="${rhs#\"*}" # Del closing string quotes
rhs="${rhs%\'*}" # Del opening string quotes
rhs="${rhs#\'*}" # Del closing string quotes
eval $lhs=\"$rhs\" # The magic happens here
fi
# tr used as a safeguard against dos line endings
done <<<$(tr -d '\r' <$configfile)
shopt -u extglob # Switching it back off after use
}
EOF
}
function chroot_run() {
echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..."
add_chroot_configuration_files $1
chroot $1 /bin/bash <<EOF
. /functions
read_config /$LIVEKITNAME.conf DEBIAN_FRONTEND_TYPE APT_CMD APT_OPTIONS LIVE_TYPE DISTRIBUTION DISTRIBUTION_TYPE PACKAGE_VARIANT COMP_TYPE
export DEBIAN_FRONTEND_TYPE APT_CMD APT_OPTIONS LIVE_TYPE DISTRIBUTION DISTRIBUTION_TYPE PACKAGE_VARIANT COMP_TYPE
${@:2}
EOF
}
# =================================================================
# =================================================================
# ======================= MODULES FUNCTIONS =======================
@ -438,6 +575,89 @@ EOF
fi
}
function chroot_cleanup() {
echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..."
set +eu
rm -f $1/functions
rm -f $1/$LIVEKITNAME.conf
rm -f $1/preinstall
rm -f $1/install
rm -f $1/install2
rm -f $1/cleanup
rm -f $1/$PACKAGE_VARIANT.list
rm -f $1/postinstall
rm -rf $1/rootcopy-install
rm -rf $1/rootcopy
rm -rf $1/patches
rm -f $1/etc/fstab
rm -f $1/etc/mtab
rm -f $1/etc/apt/sources.list~
rm -Rf $1/etc/systemd/system/timers.target.wants
rm -f $1/etc/systemd/system/multi-user.target.wants/ssh.service
rm -f $1/etc/systemd/system/multi-user.target.wants/dnsmasq.service
rm -f $1/etc/ssh/ssh_host*
rm -f $1/var/backups/*
rm -f $1/var/cache/ldconfig/*
rm -f $1/var/cache/debconf/*
rm -f $1/var/cache/fontconfig/*
rm -f $1/var/lib/apt/extended_states
rm -f $1/var/lib/systemd/random-seed
rm -f $1/var/lib/apt/lists/deb.*
rm -Rf $1/root/.local/share/mc
rm -Rf $1/root/.cache
rm -f $1/root/.wget-hsts
rm -f $1/var/lib/dpkg/*-old
rm -f $1/var/log/*
rm -f $1/var/log/*/*
rm -f $1/var/log/*/*/*
rm -f $1/var/cache/apt/archives/*.deb
rm -f $1/var/cache/apt/*.bin
rm -f $1/var/cache/debconf/*-old
rm -f $1/var/lib/dhcp/dhclient.leases
rm -f $1/root/.bash_history
rm -f $1/root/.wget-hsts
rm -Rf $1/usr/share/doc/*
rm -Rf $1/usr/share/info/*
rm -f $1/usr/share/images/fluxbox/debian-squared.jpg
rm -Rf $1/usr/share/fluxbox/nls/??*
rm -Rf $1/usr/share/gnome/help
rm -Rf $1/usr/share/locale/??
rm -Rf $1/usr/share/locale/??_*
rm -Rf $1/usr/share/locale/??@*
rm -Rf $1/usr/share/locale/???
rm -Rf $1/usr/share/i18n/locales/*_*
rm -Rf $1/usr/share/man/??
rm -Rf $1/usr/share/man/*_*
rm -Rf $1/usr/share/icons/elementaryXubuntu-dark
rm -Rf $1/usr/share/icons/gnome/256x256
rm $1/usr/share/applications/compton.desktop
rm $1/usr/share/applications/debian-uxterm.desktop
rm $1/usr/share/applications/debian-xterm.desktop
rm $1/usr/share/applications/htop.desktop
rm $1/usr/share/applications/mc.desktop
rm $1/usr/share/applications/mcedit.desktop
rm $1/usr/share/applications/pcmanfm-desktop-pref.desktop
rm $1/usr/share/applications/python2.7.desktop
rm $1/usr/share/applications/python3.7.desktop
rm $1/usr/share/applications/vim.desktop
uncompress_files $1/etc/alternatives
uncompress_files $1/usr/share/man
remove_broken_links $1/etc/alternatives
remove_broken_links $1/usr/share/man
set -eu
}
# =================================================================
#
#
@ -445,202 +665,11 @@ EOF
function module_build_cleanup() {
echo -e "=====> the ${CYAN}${FUNCNAME[0]}${ENDCOLOUR} function is executing ..."
set +e
if [ $OUTPUT = "/dev/stdout" ] && [ ! -f /dev/stdout ]; then
rm -f $MODULE_UPPER_DIR/preinstall
rm -f $MODULE_UPPER_DIR/install
rm -f $MODULE_UPPER_DIR/install2
rm -f $MODULE_UPPER_DIR/cleanup
rm -f $MODULE_UPPER_DIR/$PACKAGE_VARIANT.list
rm -f $MODULE_UPPER_DIR/postinstall
rm -rf $MODULE_UPPER_DIR/rootcopy-install
rm -rf $MODULE_UPPER_DIR/patches
rm -f $MODULE_UPPER_DIR/etc/fstab
rm -f $MODULE_UPPER_DIR/etc/mtab
rm -f $MODULE_UPPER_DIR/etc/apt/sources.list~
rm -Rf $MODULE_UPPER_DIR/etc/systemd/system/timers.target.wants
rm -f $MODULE_UPPER_DIR/etc/systemd/system/multi-user.target.wants/ssh.service
rm -f $MODULE_UPPER_DIR/etc/systemd/system/multi-user.target.wants/dnsmasq.service
rm -f $MODULE_UPPER_DIR/etc/resolv.conf
rm -f $MODULE_UPPER_DIR/etc/ssh/ssh_host*
rm -f $MODULE_UPPER_DIR/var/backups/*
rm -f $MODULE_UPPER_DIR/var/cache/ldconfig/*
rm -f $MODULE_UPPER_DIR/var/cache/debconf/*
rm -f $MODULE_UPPER_DIR/var/cache/fontconfig/*
rm -f $MODULE_UPPER_DIR/var/lib/apt/extended_states
rm -f $MODULE_UPPER_DIR/var/lib/systemd/random-seed
rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/deb.*
rm -Rf $MODULE_UPPER_DIR/root/.local/share/mc
rm -Rf $MODULE_UPPER_DIR/root/.cache
rm -f $MODULE_UPPER_DIR/root/.wget-hsts
rm -f $MODULE_UPPER_DIR/var/lib/dpkg/*-old
rm -f $MODULE_UPPER_DIR/var/log/*
rm -f $MODULE_UPPER_DIR/var/log/*/*
rm -f $MODULE_UPPER_DIR/var/log/*/*/*
rm -f $MODULE_UPPER_DIR/var/cache/apt/archives/*.deb
rm -f $MODULE_UPPER_DIR/var/cache/apt/*.bin
rm -f $MODULE_UPPER_DIR/var/cache/debconf/*-old
rm -f $MODULE_UPPER_DIR/var/lib/dhcp/dhclient.leases
rm -f $MODULE_UPPER_DIR/root/.bash_history
rm -f $MODULE_UPPER_DIR/root/.wget-hsts
rm -Rf $MODULE_UPPER_DIR/usr/share/doc/*
rm -Rf $MODULE_UPPER_DIR/usr/share/info/*
rm -f $MODULE_UPPER_DIR/usr/share/images/fluxbox/debian-squared.jpg
rm -Rf $MODULE_UPPER_DIR/usr/share/fluxbox/nls/??*
rm -Rf $MODULE_UPPER_DIR/usr/share/gnome/help
rm -Rf $MODULE_UPPER_DIR/usr/share/locale/??
rm -Rf $MODULE_UPPER_DIR/usr/share/locale/??_*
rm -Rf $MODULE_UPPER_DIR/usr/share/locale/??@*
rm -Rf $MODULE_UPPER_DIR/usr/share/locale/???
rm -Rf $MODULE_UPPER_DIR/usr/share/i18n/locales/*_*
rm -Rf $MODULE_UPPER_DIR/usr/share/man/??
rm -Rf $MODULE_UPPER_DIR/usr/share/man/*_*
rm -Rf $MODULE_UPPER_DIR/usr/share/icons/elementaryXubuntu-dark
rm -Rf $MODULE_UPPER_DIR/usr/share/icons/gnome/256x256
rm $MODULE_UPPER_DIR/usr/share/applications/compton.desktop
rm $MODULE_UPPER_DIR/usr/share/applications/debian-uxterm.desktop
#rm $MODULE_UPPER_DIR/usr/share/applications/debian-xterm.desktop
#rm $MODULE_UPPER_DIR/usr/share/applications/htop.desktop
#rm $MODULE_UPPER_DIR/usr/share/applications/mc.desktop
rm $MODULE_UPPER_DIR/usr/share/applications/mcedit.desktop
rm $MODULE_UPPER_DIR/usr/share/applications/pcmanfm-desktop-pref.desktop
rm $MODULE_UPPER_DIR/usr/share/applications/python2.7.desktop
rm $MODULE_UPPER_DIR/usr/share/applications/python3.7.desktop
rm $MODULE_UPPER_DIR/usr/share/applications/vim.desktop
# Unzip gzipped files (man pages), so LZMA can compress 2times better.
# First we fix symlinks, then uncompress files
# $1 = search directory
uncompress_files() {
local LINK LINE
find "$1" -type l -name "*.gz" | while read LINE; do
LINK="$(readlink "$LINE" | sed -r 's/.gz$//')"
FILE="$(echo "$LINE" | sed -r 's/.gz$//')"
ln -sfn "$LINK" "$FILE"
rm -f "$LINE"
done
find "$1" -type f -name "*.gz" | xargs -r gunzip
}
uncompress_files $MODULE_UPPER_DIR/etc/alternatives
uncompress_files $MODULE_UPPER_DIR/usr/share/man
# remove broken links
# $1 = search directory
remove_broken_links() {
find "$1" -type l -exec test ! -e {} \; -print | xargs rm -vf
}
remove_broken_links $MODULE_UPPER_DIR/etc/alternatives
remove_broken_links $MODULE_UPPER_DIR/usr/share/man
chroot_cleanup $MODULE_UPPER_DIR
else
rm -f $MODULE_UPPER_DIR/preinstall >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/install >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/install2 >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/cleanup >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/$PACKAGE_VARIANT.list >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/postinstall >>$OUTPUT 2>&1
rm -rf $MODULE_UPPER_DIR/rootcopy-install >>$OUTPUT 2>&1
rm -rf $MODULE_UPPER_DIR/patches >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/etc/fstab >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/etc/mtab >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/etc/apt/sources.list~ >>$OUTPUT 2>&1
rm -Rf $MODULE_UPPER_DIR/etc/systemd/system/timers.target.wants >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/etc/systemd/system/multi-user.target.wants/ssh.service >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/etc/systemd/system/multi-user.target.wants/dnsmasq.service >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/etc/resolv.conf >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/etc/ssh/ssh_host* >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/var/backups/* >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/var/cache/ldconfig/* >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/var/cache/debconf/* >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/var/cache/fontconfig/* >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/var/lib/apt/extended_states >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/var/lib/systemd/random-seed >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/var/lib/apt/lists/deb.* >>$OUTPUT 2>&1
rm -Rf $MODULE_UPPER_DIR/root/.local/share/mc >>$OUTPUT 2>&1
rm -Rf $MODULE_UPPER_DIR/root/.cache >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/root/.wget-hsts >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/var/lib/dpkg/*-old >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/var/log/* >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/var/log/*/* >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/var/log/*/*/* >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/var/cache/apt/archives/*.deb >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/var/cache/apt/*.bin >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/var/cache/debconf/*-old >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/var/lib/dhcp/dhclient.leases >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/root/.bash_history >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/root/.wget-hsts >>$OUTPUT 2>&1
rm -Rf $MODULE_UPPER_DIR/usr/share/doc/* >>$OUTPUT 2>&1
rm -Rf $MODULE_UPPER_DIR/usr/share/info/* >>$OUTPUT 2>&1
rm -f $MODULE_UPPER_DIR/usr/share/images/fluxbox/debian-squared.jpg >>$OUTPUT 2>&1
rm -Rf $MODULE_UPPER_DIR/usr/share/fluxbox/nls/??* >>$OUTPUT 2>&1
rm -Rf $MODULE_UPPER_DIR/usr/share/gnome/help >>$OUTPUT 2>&1
rm -Rf $MODULE_UPPER_DIR/usr/share/locale/?? >>$OUTPUT 2>&1
rm -Rf $MODULE_UPPER_DIR/usr/share/locale/??_* >>$OUTPUT 2>&1
rm -Rf $MODULE_UPPER_DIR/usr/share/locale/??@* >>$OUTPUT 2>&1
rm -Rf $MODULE_UPPER_DIR/usr/share/locale/??? >>$OUTPUT 2>&1
rm -Rf $MODULE_UPPER_DIR/usr/share/i18n/locales/*_* >>$OUTPUT 2>&1
rm -Rf $MODULE_UPPER_DIR/usr/share/man/?? >>$OUTPUT 2>&1
rm -Rf $MODULE_UPPER_DIR/usr/share/man/*_* >>$OUTPUT 2>&1
rm -Rf $MODULE_UPPER_DIR/usr/share/icons/elementaryXubuntu-dark >>$OUTPUT 2>&1
rm -Rf $MODULE_UPPER_DIR/usr/share/icons/gnome/256x256 >>$OUTPUT 2>&1
rm $MODULE_UPPER_DIR/usr/share/applications/compton.desktop >>$OUTPUT 2>&1
rm $MODULE_UPPER_DIR/usr/share/applications/debian-uxterm.desktop >>$OUTPUT 2>&1
#rm $MODULE_UPPER_DIR/usr/share/applications/debian-xterm.desktop >>$OUTPUT 2>&1
#rm $MODULE_UPPER_DIR/usr/share/applications/htop.desktop >>$OUTPUT 2>&1
#rm $MODULE_UPPER_DIR/usr/share/applications/mc.desktop >>$OUTPUT 2>&1
rm $MODULE_UPPER_DIR/usr/share/applications/mcedit.desktop >>$OUTPUT 2>&1
rm $MODULE_UPPER_DIR/usr/share/applications/pcmanfm-desktop-pref.desktop >>$OUTPUT 2>&1
rm $MODULE_UPPER_DIR/usr/share/applications/python2.7.desktop >>$OUTPUT 2>&1
rm $MODULE_UPPER_DIR/usr/share/applications/python3.7.desktop >>$OUTPUT 2>&1
rm $MODULE_UPPER_DIR/usr/share/applications/vim.desktop >>$OUTPUT 2>&1
# Unzip gzipped files (man pages), so LZMA can compress 2times better.
# First we fix symlinks, then uncompress files
# $1 = search directory
uncompress_files() {
local LINK LINE
find "$1" -type l -name "*.gz" | while read LINE; do
LINK="$(readlink "$LINE" | sed -r 's/.gz$//')"
FILE="$(echo "$LINE" | sed -r 's/.gz$//')"
ln -sfn "$LINK" "$FILE"
rm -f "$LINE"
done
find "$1" -type f -name "*.gz" | xargs -r gunzip >>$OUTPUT 2>&1
}
uncompress_files $MODULE_UPPER_DIR/etc/alternatives >>$OUTPUT 2>&1
uncompress_files $MODULE_UPPER_DIR/usr/share/man >>$OUTPUT 2>&1
# remove broken links
# $1 = search directory
remove_broken_links() {
find "$1" -type l -exec test ! -e {} \; -print | xargs rm -vf >>$OUTPUT 2>&1
}
remove_broken_links $MODULE_UPPER_DIR/etc/alternatives >>$OUTPUT 2>&1
remove_broken_links $MODULE_UPPER_DIR/usr/share/man >>$OUTPUT 2>&1
chroot_cleanup $MODULE_UPPER_DIR >>$OUTPUT 2>&1
fi
set -e
}
# =================================================================
@ -652,7 +681,11 @@ function build_modules() {
MODULES_DIR=$CURRENT_DIR/build
cd $CURRENT_DIR/modules
if [ -d $CURRENT_DIR/modules ]; then
cd $CURRENT_DIR/modules
else
help
fi
for MODULE in *; do
MODULE_UPPER_DIR="$MODULES_DIR/$MODULE-upper"
@ -663,21 +696,23 @@ function build_modules() {
module_chroot_mount_fs
if [ $OUTPUT = "/dev/stdout" ] && [ ! -f /dev/stdout ]; then
chroot_run $MODULE_MERGED_DIR $APT_CMD update
else
chroot_run $MODULE_MERGED_DIR $APT_CMD update >>$OUTPUT 2>&1
fi
# run pre-install script
if [ -f $CURRENT_DIR/modules/$MODULE/preinstall ]; then
cp $CURRENT_DIR/modules/$MODULE/preinstall $MODULE_MERGED_DIR/preinstall
chmod +x $MODULE_MERGED_DIR/preinstall
chroot $MODULE_MERGED_DIR /usr/bin/env \
OUTPUT=$OUTPUT \
BUILD_TEST_ISO=$BUILD_TEST_ISO \
DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \
APT_CMD=$APT_CMD \
APT_OPTIONS=$APT_OPTIONS \
APT_OPTIONS2=$APT_OPTIONS2 \
LIVE_TYPE=$LIVE_TYPE \
DISTRIBUTION=$DISTRIBUTION \
PACKAGE_VARIANT=$PACKAGE_VARIANT \
/preinstall >>$OUTPUT 2>&1
if [ -f $SCRIPT_DIR/linux-live/modules/$MODULE/preinstall ]; then
if [ $OUTPUT = "/dev/stdout" ] && [ ! -f /dev/stdout ]; then
cp $SCRIPT_DIR/linux-live/modules/$MODULE/preinstall $MODULE_MERGED_DIR/preinstall
chmod +x $MODULE_MERGED_DIR/preinstall
chroot_run $MODULE_MERGED_DIR /preinstall
else
cp $SCRIPT_DIR/linux-live/modules/$MODULE/preinstall $MODULE_MERGED_DIR/preinstall
chmod +x $MODULE_MERGED_DIR/preinstall
chroot_run $MODULE_MERGED_DIR /preinstall >>$OUTPUT 2>&1
fi
fi
# copy files
@ -702,27 +737,9 @@ function build_modules() {
cp $CURRENT_DIR/modules/$MODULE/$PACKAGE_VARIANT.list $MODULE_MERGED_DIR/$PACKAGE_VARIANT.list
fi
if [ $OUTPUT = "/dev/stdout" ] && [ ! -f /dev/stdout ]; then
chroot $MODULE_MERGED_DIR /usr/bin/env \
OUTPUT=$OUTPUT \
DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \
APT_CMD=$APT_CMD \
APT_OPTIONS=$APT_OPTIONS \
APT_OPTIONS2=$APT_OPTIONS2 \
LIVE_TYPE=$LIVE_TYPE \
DISTRIBUTION=$DISTRIBUTION \
PACKAGE_VARIANT=$PACKAGE_VARIANT \
/install
chroot_run $MODULE_MERGED_DIR /install
else
chroot $MODULE_MERGED_DIR /usr/bin/env \
OUTPUT=$OUTPUT \
DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \
APT_CMD=$APT_CMD \
APT_OPTIONS=$APT_OPTIONS \
APT_OPTIONS2=$APT_OPTIONS2 \
LIVE_TYPE=$LIVE_TYPE \
DISTRIBUTION=$DISTRIBUTION \
PACKAGE_VARIANT=$PACKAGE_VARIANT \
/install >>$OUTPUT 2>&1
chroot_run $MODULE_MERGED_DIR /install >>$OUTPUT 2>&1
fi
fi
@ -735,27 +752,9 @@ function build_modules() {
(cd $CURRENT_DIR/modules/$MODULE/patches && cp --parents -afr * $MODULE_MERGED_DIR/patches/)
fi
if [ $OUTPUT = "/dev/stdout" ] && [ ! -f /dev/stdout ]; then
chroot $MODULE_MERGED_DIR /usr/bin/env \
OUTPUT=$OUTPUT \
DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \
APT_CMD=$APT_CMD \
APT_OPTIONS=$APT_OPTIONS \
APT_OPTIONS2=$APT_OPTIONS2 \
LIVE_TYPE=$LIVE_TYPE \
DISTRIBUTION=$DISTRIBUTION \
PACKAGE_VARIANT=$PACKAGE_VARIANT \
/install2
chroot_run $MODULE_MERGED_DIR /install2
else
chroot $MODULE_MERGED_DIR /usr/bin/env \
OUTPUT=$OUTPUT \
DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \
APT_CMD=$APT_CMD \
APT_OPTIONS=$APT_OPTIONS \
APT_OPTIONS2=$APT_OPTIONS2 \
LIVE_TYPE=$LIVE_TYPE \
DISTRIBUTION=$DISTRIBUTION \
PACKAGE_VARIANT=$PACKAGE_VARIANT \
/install2 >>$OUTPUT 2>&1
chroot_run $MODULE_MERGED_DIR /install2 >>$OUTPUT 2>&1
fi
fi
@ -775,27 +774,9 @@ function build_modules() {
cp $CURRENT_DIR/modules/$MODULE/postinstall $MODULE_MERGED_DIR/postinstall
chmod +x $MODULE_MERGED_DIR/postinstall
if [ $OUTPUT = "/dev/stdout" ] && [ ! -f /dev/stdout ]; then
chroot $MODULE_MERGED_DIR /usr/bin/env \
OUTPUT=$OUTPUT \
DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \
APT_CMD=$APT_CMD \
APT_OPTIONS=$APT_OPTIONS \
APT_OPTIONS2=$APT_OPTIONS2 \
LIVE_TYPE=$LIVE_TYPE \
DISTRIBUTION=$DISTRIBUTION \
PACKAGE_VARIANT=$PACKAGE_VARIANT \
/postinstall
chroot_run $MODULE_MERGED_DIR /postinstall
else
chroot $MODULE_MERGED_DIR /usr/bin/env \
OUTPUT=$OUTPUT \
DEBIAN_FRONTEND_TYPE=$DEBIAN_FRONTEND_TYPE \
APT_CMD=$APT_CMD \
APT_OPTIONS=$APT_OPTIONS \
APT_OPTIONS2=$APT_OPTIONS2 \
LIVE_TYPE=$LIVE_TYPE \
DISTRIBUTION=$DISTRIBUTION \
PACKAGE_VARIANT=$PACKAGE_VARIANT \
/postinstall >>$OUTPUT 2>&1
chroot_run $MODULE_MERGED_DIR /postinstall >>$OUTPUT 2>&1
fi
fi

23
modules/06-virtualbox/install

@ -2,10 +2,25 @@
set -e # exit on error
set -o pipefail # exit on pipeline error
set -u # treat unset variable as error
#set -u # treat unset variable as error
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
if [ -z $DISTRIBUTION ]; then
DISTRIBUTION="bullseye"
fi
if [ -z $APT_CMD ]; then
APT_CMD="apt-get"
fi
if [ -z $APT_OPTIONS ]; then
APT_OPTIONS="-y"
fi
if [ -z $OUTPUT ]; then
OUTPUT="/dev/stdout"
fi
VBOX_VERSION=$(wget -O- https://download.virtualbox.org/virtualbox/LATEST.TXT)
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A2F683C52980AECF
echo "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian $DISTRIBUTION contrib" >/etc/apt/sources.list.d/virtualbox.list
@ -14,5 +29,11 @@ echo "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian $DISTRI
$APT_CMD update >>$OUTPUT 2>&1 &&
$APT_CMD install $APT_OPTIONS linux-headers-amd64 gcc make >>$OUTPUT 2>&1
echo virtualbox-ext-pack virtualbox-ext-pack/license select true | sudo debconf-set-selections
# install packages
$APT_CMD install $APT_OPTIONS virtualbox-6.1 >>$OUTPUT 2>&1
wget -c https://download.virtualbox.org/virtualbox/6.1.30/Oracle_VM_VirtualBox_Extension_Pack-$VBOX_VERSION.vbox-extpack
VBoxManage extpack install --replace $SCRIPT_DIR/Oracle_VM_VirtualBox_Extension_Pack-$VBOX_VERSION.vbox-extpack

29
modules/06-virtualbox/postinstall

@ -1,6 +1,31 @@
#!/bin/bash
$APT_CMD autoremove $APT_OPTIONS $APT_OPTIONS2 \
linux-headers-amd64 gcc make >>$OUTPUT 2>&1
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
if [ -z $DISTRIBUTION ]; then
DISTRIBUTION="bullseye"
fi
if [ -z $APT_CMD ]; then
APT_CMD="apt-get"
fi
if [ -z $APT_OPTIONS ]; then
APT_OPTIONS="-y"
fi
if [ -z $OUTPUT ]; then
OUTPUT="/dev/stdout"
fi
VBOX_VERSION=$(wget -O- https://download.virtualbox.org/virtualbox/LATEST.TXT)
$APT_CMD autoremove $APT_OPTIONS \
binutils binutils-common binutils-x86-64-linux-gnu \
gcc gcc-10 libasan6 libatomic1 libbinutils libcc1-0 \
libctf-nobfd0 libctf0 libgcc-10-dev libitm1 liblsan0 \
libquadmath0 libtsan0 libubsan1 linux-compiler-gcc-10-x86 \
linux-headers-5.10.0-9-amd64 linux-headers-5.10.0-9-common \
linux-headers-amd64 linux-kbuild-5.10 make >>$OUTPUT 2>&1
rm -f $SCRIPT_DIR/Oracle_VM_VirtualBox_Extension_Pack-$VBOX_VERSION.vbox-extpack
rm -Rf /usr/share/icons/hicolor/256x256 >>$OUTPUT 2>&1
rm -Rf /usr/share/icons/gnome/256x256 >>$OUTPUT 2>&1

9
modules/07-vboxextpack/install

@ -1,9 +0,0 @@
#!/bin/bash
set -e # exit on error
set -o pipefail # exit on pipeline error
set -u # treat unset variable as error
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
VBoxManage extpack install --replace /Oracle_VM_VirtualBox_Extension_Pack-6.1.28.vbox-extpack

3
modules/07-vboxextpack/postinstall

@ -1,3 +0,0 @@
#!/bin/bash
rm -f /Oracle_VM_VirtualBox_Extension_Pack-6.1.28.vbox-extpack

BIN
modules/07-vboxextpack/rootcopy-install/Oracle_VM_VirtualBox_Extension_Pack-6.1.28.vbox-extpack

Binary file not shown.
Loading…
Cancel
Save