Browse Source

cmdline support

master
crims0n 4 years ago
parent
commit
5210709acc
  1. 153
      linux-live/basesystem/01-core/rootcopy-install/usr/bin/cmdline_parser
  2. 12
      linux-live/basesystem/01-core/rootcopy-install/usr/lib/systemd/system/cmdline-parser.service
  3. 4
      linux-live/buildconfig
  4. 60
      linux-live/minioslib
  5. 19
      linux-live/modules/06-virtmanager/install
  6. 4
      linux-live/modules/06-virtmanager/postinstall
  7. 18
      modules/06-virtualbox/install
  8. 6
      modules/06-virtualbox/postinstall
  9. 9
      modules/07-vboxextpack/install
  10. 3
      modules/07-vboxextpack/postinstall
  11. BIN
      modules/07-vboxextpack/rootcopy-install/Oracle_VM_VirtualBox_Extension_Pack-6.1.28.vbox-extpack

153
linux-live/basesystem/01-core/rootcopy-install/usr/bin/cmdline_parser

@ -0,0 +1,153 @@
#!/bin/bash
#
# Сommand line parsing script.
# Author: crims0n. <http://minios.ru>
#
for i in $(cat /proc/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
;;
ssh)
SSH=true
shift # past argument with no value
;;
cloud)
CLOUD=true
shift # past argument with no value
;;
*)
# unknown option
;;
esac
done
if [ -z "$ROOT_PASSWORD" ]; then
ROOT_PASSWORD="toor"
fi
echo "Set up password for user 'root'"
echo root:$ROOT_PASSWORD | chpasswd
if [ "$CLOUD" != "true" ]; then
if [ -z "$USER_NAME" ]; then
USER_NAME="live"
fi
echo "Set up user '$USER_NAME'"
adduser --uid 1000 --gecos '' $USER_NAME --disabled-password
if [ -z "$USER_PASSWORD" ]; then
USER_PASSWORD="evil"
fi
echo "Set up password for user '$USER_NAME'"
echo $USER_NAME:$USER_PASSWORD | chpasswd
usermod -a -G sudo $USER_NAME
if [ "$SSH" = "true" ]; then
systemctl enable ssh-keygen
systemctl enable ssh
else
systemctl disable ssh-keygen
systemctl disable ssh
fi
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
rm -rf /home/live
fi
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
if [ "$CLOUD" != "true" ]; 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.
:::: :::: ::::::::::: :::: ::: ::::::::::: :::::::: :::::::: 
+:+:+: :+:+:+ :+: :+:+: :+: :+: :+: :+: :+: :+: 
+:+ +:+:+ +:+ +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+ 
+#+ +:+ +#+ +#+ +#+ +:+ +#+ +#+ +#+ +:+ +#++:++#++ 
+#+ +#+ +#+ +#+ +#+#+# +#+ +#+ +#+ +#+ 
#+# #+# #+# #+# #+#+# #+# #+# #+# #+# #+# 
### ### ########### ### #### ########### ######## ######## 
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" $USERNAME
EOF
fi

12
linux-live/basesystem/01-core/rootcopy-install/usr/lib/systemd/system/cmdline-parser.service

@ -0,0 +1,12 @@
[Unit]
Description=Сommand line parsing script
Before=ssh-keygen.service
[Service]
Type=oneshot
ExecStart=/usr/bin/cmdline_parser
RemainAfterExit=true
StandardOutput=journal
[Install]
WantedBy=multi-user.target

4
linux-live/buildconfig

@ -6,7 +6,7 @@ DISTRIBUTION_TYPE="debian"
# distribution
# дистрибутив
DISTRIBUTION="buster"
DISTRIBUTION="bullseye"
# distribution arch
# note: stretch only works with amd64
@ -14,7 +14,7 @@ DISTRIBUTION="buster"
# для заметки: stretch работает только с amd64
DISTRIBUTION_ARCH="amd64"
COMP_TYPE="zstd"
COMP_TYPE="xz"
# bootstrap variant (used to build Ubuntu)
# вариант bootstrap (используется для сборки Ubuntu)

60
linux-live/minioslib

@ -41,7 +41,7 @@ function common_variables() {
elif [ $DISTRIBUTION_ARCH = "i386" ]; then
KERNEL_ARCH="686-pae"
#KERNEL_ARCH="686"
PACKAGE_VARIANT="minimal"
#PACKAGE_VARIANT="minimal"
elif [ $DISTRIBUTION_ARCH = "arm64" ]; then
KERNEL_ARCH="arm64"
fi
@ -1514,18 +1514,19 @@ function chroot_pkg_install() {
function chroot_configure() {
current_process
if [ $CLOUD != "true" ]; then
(cd /linux-live/basesystem/01-core/rootcopy-install && cp --parents -afr * /)
echo "Set up password for user 'root'" >>$OUTPUT 2>&1
echo root:$ROOT_PASSWORD | chpasswd >>$OUTPUT 2>&1
(cd /linux-live/basesystem/01-core/rootcopy-install && cp --parents -afr * /)
# if [ $CLOUD != "true" ]; then
# echo "Set up password for user 'root'" >>$OUTPUT 2>&1
# echo root:$ROOT_PASSWORD | chpasswd >>$OUTPUT 2>&1
echo "Set up user '$USER_NAME'" >>$OUTPUT 2>&1
adduser --uid 1000 --gecos '' $USER_NAME --disabled-password >>$OUTPUT 2>&1
echo "Set up password for user '$USER_NAME'" >>$OUTPUT 2>&1
echo $USER_NAME:$USER_PASSWORD | chpasswd >>$OUTPUT 2>&1
usermod -a -G sudo $USER_NAME
# echo "Set up user '$USER_NAME'" >>$OUTPUT 2>&1
# adduser --uid 1000 --gecos '' $USER_NAME --disabled-password >>$OUTPUT 2>&1
# echo "Set up password for user '$USER_NAME'" >>$OUTPUT 2>&1
# echo $USER_NAME:$USER_PASSWORD | chpasswd >>$OUTPUT 2>&1
# usermod -a -G sudo $USER_NAME
: 'if [ ! -d /home/$USER_NAME ]; then
: 'if [ ! -d /home/$USER_NAME ]; then
mkdir -p /home/$USER_NAME
fi
cp -r /etc/skel/* /home/$USER_NAME
@ -1533,17 +1534,16 @@ function chroot_configure() {
chown $USER_NAME:$USER_NAME /home/$USER_NAME
chown -R $USER_NAME:$USER_NAME /home/$USER_NAME'
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
else
echo "Set up password for user 'root'" >>$OUTPUT 2>&1
echo root:$ROOT_PASSWORD | chpasswd >>$OUTPUT 2>&1
(cd /linux-live/basesystem/01-core/rootcopy-install && cp --parents -afr * /)
rm -rf /home/live
fi
# 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
# else
# echo "Set up password for user 'root'" >>$OUTPUT 2>&1
# echo root:$ROOT_PASSWORD | chpasswd >>$OUTPUT 2>&1
# rm -rf /home/live
# fi
if [ ! -d /etc/NetworkManager ]; then
echo "Enable dhclient.service autostart." >>$OUTPUT 2>&1
@ -1608,12 +1608,12 @@ StandardOutput=journal
[Install]
WantedBy=multi-user.target
EOF
if [ $CLOUD != "true" ]; then
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
fi
systemctl enable ssh-keygen >>$OUTPUT 2>&1
systemctl enable ssh >>$OUTPUT 2>&1
#if [ $CLOUD != "true" ]; then
# 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
#fi
#systemctl enable ssh-keygen >>$OUTPUT 2>&1
#systemctl enable ssh >>$OUTPUT 2>&1
fi
if [ ! -f /usr/share/sudo ]; then
@ -1632,7 +1632,7 @@ echo "Sudo is not installed. Run the command as root or install sudo."
EOF
fi
if [ $CLOUD != "true" ]; then
: ' if [ $CLOUD != "true" ]; then
cat <<EOF >/etc/issue
@ -1698,7 +1698,7 @@ EOF
EOF
fi
fi'
}
# =================================================================

19
linux-live/modules/06-virtmanager/install

@ -0,0 +1,19 @@
#!/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")")"
# install packages
$APT_CMD update >>$OUTPUT 2>&1 &&
$APT_CMD install $APT_OPTIONS \
qemu-kvm \
libvirt-clients \
libvirt-daemon-system \
bridge-utils \
virt-manager \
gir1.2-spiceclientgtk-3.0 >>$OUTPUT 2>&1
usermod -aG libvirt live

4
linux-live/modules/06-virtmanager/postinstall

@ -0,0 +1,4 @@
#!/bin/bash
rm -Rf /usr/share/icons/hicolor/256x256 >>$OUTPUT 2>&1
rm -Rf /usr/share/icons/gnome/256x256 >>$OUTPUT 2>&1

18
modules/06-virtualbox/install

@ -0,0 +1,18 @@
#!/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")")"
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
# install packages
$APT_CMD update >>$OUTPUT 2>&1 &&
$APT_CMD install $APT_OPTIONS linux-headers-amd64 gcc make >>$OUTPUT 2>&1
# install packages
$APT_CMD install $APT_OPTIONS virtualbox-6.1 >>$OUTPUT 2>&1

6
modules/06-virtualbox/postinstall

@ -0,0 +1,6 @@
#!/bin/bash
$APT_CMD autoremove $APT_OPTIONS $APT_OPTIONS2 \
linux-headers-amd64 gcc make >>$OUTPUT 2>&1
rm -Rf /usr/share/icons/gnome/256x256 >>$OUTPUT 2>&1

9
modules/07-vboxextpack/install

@ -0,0 +1,9 @@
#!/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

@ -0,0 +1,3 @@
#!/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