#!/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 ;; 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 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 if [ "$USER_NAME" != "root" ]; then #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 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 if [ "$USER_NAME" != "live" ] && [ "$USER_NAME" != "root" ]; then rm -rf /home/live # create user directories 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 elif [ "$USER_NAME" = "root" ]; then 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 if [ "$USER_NAME" != "root" ]; then 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 fi if [ "$CLOUD" != "true" ]; then if [ "$USER_NAME" != "root" ]; 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. :::: :::: ::::::::::: :::: ::: ::::::::::: :::::::: ::::::::  +:+:+: :+:+:+ :+: :+:+: :+: :+: :+: :+: :+: :+:  +:+ +:+:+ +:+ +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+  +#+ +:+ +#+ +#+ +#+ +:+ +#+ +#+ +#+ +:+ +#++:++#++  +#+ +#+ +#+ +#+ +#+#+# +#+ +#+ +#+ +#+  #+# #+# #+# #+# #+#+# #+# #+# #+# #+# #+#  ### ### ########### ### #### ########### ######## ########  Root login name: root Password: $ROOT_PASSWORD EOF fi 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" $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 [ -z "$HOST_NAME" ]; then HOST_NAME="minios" fi echo $HOST_NAME >/etc/hostname if [ -z "$DEFAULT_TARGET" ]; then $DEFAULT_TARGET="graphical" fi systemctl set-default $DEFAULT_TARGET echo "USER_NAME=$USER_NAME" echo "USER_PASSWORD=$USER_PASSWORD" echo "ROOT_PASSWORD=$ROOT_PASSWORD" echo "HOSTNAME=$HOSTNAME" echo "SSH=$SSH" echo "CLOUD=$CLOUD"