diff --git a/linux-live/basesystem/01-core/rootcopy-install/usr/bin/cmdline_parser b/linux-live/basesystem/01-core/rootcopy-install/usr/bin/cmdline_parser deleted file mode 100755 index b10461f..0000000 --- a/linux-live/basesystem/01-core/rootcopy-install/usr/bin/cmdline_parser +++ /dev/null @@ -1,154 +0,0 @@ -#!/bin/bash -# -# Сommand line parsing script. -# Author: crims0n. -# - -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 - - 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 - -if [ "$SSH" != "true" ]; then -# systemctl enable ssh-keygen -# systemctl enable ssh -#else - systemctl disable ssh-keygen - systemctl disable ssh -fi - -cat </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 </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 </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 </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 \ No newline at end of file diff --git a/linux-live/basesystem/01-core/rootcopy-install/usr/lib/systemd/system/cmdline-parser.service b/linux-live/basesystem/01-core/rootcopy-install/usr/lib/systemd/system/cmdline-parser.service deleted file mode 100644 index 5a1e5cc..0000000 --- a/linux-live/basesystem/01-core/rootcopy-install/usr/lib/systemd/system/cmdline-parser.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Command line parsing script -Before=ssh-keygen.service - -[Service] -Type=oneshot -ExecStart=/usr/bin/cmdline_parser -RemainAfterExit=true -StandardOutput=journal - -[Install] -WantedBy=multi-user.target \ No newline at end of file diff --git a/linux-live/buildconfig b/linux-live/buildconfig index ff08f3e..dfecf99 100644 --- a/linux-live/buildconfig +++ b/linux-live/buildconfig @@ -83,4 +83,6 @@ USE_ROOTFS="1" #ROOT_PASSWORD="uG5TYt5sIzHe" ROOT_PASSWORD="toor" USER_NAME="live" -USER_PASSWORD="evil" \ No newline at end of file +USER_PASSWORD="evil" + +CMDLINE_PARSER="true" \ No newline at end of file diff --git a/linux-live/initramfs/init b/linux-live/initramfs/init index 1e49867..0ca1a0f 100644 --- a/linux-live/initramfs/init +++ b/linux-live/initramfs/init @@ -54,6 +54,9 @@ union_append_bundles "$BUNDLES" "$UNION" # rootcopy copy_rootcopy_content "$DATA" "$UNION" +# configure +minios_configure "$UNION" + debug_shell # create fstab fstab_create "$UNION" "$DATAMNT" debug_shell diff --git a/linux-live/livekitlib b/linux-live/livekitlib index f162496..cc401cc 100644 --- a/linux-live/livekitlib +++ b/linux-live/livekitlib @@ -776,6 +776,148 @@ fstab_create() { done } +minios_configure() { + debug_log "minios_configure" "$*" + + USER_NAME=$(cmdline_value user_name) + USER_PASSWORD=$(cmdline_value user_password) + ROOT_PASSWORD=$(cmdline_value root_password) + + if grep -vq ssh /proc/cmdline; then + SSH="true" + fi + + if grep -vq cloud /proc/cmdline; then + CLOUD="true" + fi + + 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'" + chroot $1 /bin/bash -c "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'" + chroot $1 /bin/bash -c "echo $USER_NAME:$USER_PASSWORD | chpasswd" + chroot $1 /bin/bash -c "usermod -a -G sudo $USER_NAME" + + chroot $1 /bin/bash -c "sed -i 's,#PermitRootLogin prohibit-password,PermitRootLogin yes,g' /etc/ssh/sshd_config" + chroot $1 /bin/bash -c "sed -i 's,#PasswordAuthentication yes,PasswordAuthentication yes,g' /etc/ssh/sshd_config" + else + chroot $1 /bin/bash -c "rm -rf /home/live" + fi + + if [ "$SSH" = "true" ]; then + sleep 3 + chroot $1 /bin/bash -c "systemctl enable ssh-keygen" + echo "ssh-keygen is enabled" + sleep 3 + chroot $1 /bin/bash -c "systemctl enable ssh" + echo "ssh is enabled" + sleep 3 + else + chroot $1 /bin/bash -c "systemctl disable ssh-keygen" + chroot $1 /bin/bash -c "systemctl disable ssh" + fi + cat <$1/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 <$1/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 <$1/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 $1/usr/lib/systemd/system/xorg.service ]; then + cat <$1/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 + +} + # Change root and execute init # $1 = where to change root # diff --git a/linux-live/minioslib b/linux-live/minioslib index d02ce48..c34518c 100644 --- a/linux-live/minioslib +++ b/linux-live/minioslib @@ -1516,9 +1516,9 @@ function chroot_configure() { (cd /linux-live/basesystem/01-core/rootcopy-install && cp --parents -afr * /) - if [ -f /usr/lib/systemd/system/cmdline-parser.service ]; then - echo "Enable cmdline-parser.service autostart." >>$OUTPUT 2>&1 - systemctl enable cmdline-parser.service >>$OUTPUT 2>&1 + if [ "$CMDLINE_PARSER" = "true" ]; then + #echo "Enable cmdline-parser.service autostart." >>$OUTPUT 2>&1 + #systemctl enable cmdline-parser.service >>$OUTPUT 2>&1 echo "Set up password for user 'root'" >>$OUTPUT 2>&1 echo root:$ROOT_PASSWORD | chpasswd >>$OUTPUT 2>&1 else