#!/bin/bash # # Сommand line parsing script. # Author: crims0n. # 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 ;; ssh) SSH=true shift # past argument with no value ;; cloud) CLOUD=true shift # past argument with no value ;; *) # unknown option ;; esac done echo "USER_NAME=$USER_NAME" echo "USER_PASSWORD=$USER_PASSWORD" echo "ROOT_PASSWORD=$ROOT_PASSWORD" echo "SSH=$SSH" echo "CLOUD=$CLOUD" sleep 5 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