crims0n 4 years ago
parent
commit
c4b5408c26
  1. 154
      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. 3
      linux-live/initramfs/init
  5. 142
      linux-live/livekitlib
  6. 6
      linux-live/minioslib

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

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

@ -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

4
linux-live/buildconfig

@ -83,4 +83,6 @@ USE_ROOTFS="1"
#ROOT_PASSWORD="uG5TYt5sIzHe"
ROOT_PASSWORD="toor"
USER_NAME="live"
USER_PASSWORD="evil"
USER_PASSWORD="evil"
CMDLINE_PARSER="true"

3
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

142
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 <<EOF >$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 <<EOF >$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 <<EOF >$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 <<EOF >$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
#

6
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

Loading…
Cancel
Save