OSDN Git Service

[update] : Create user by casper
authormk-linux419 <m.k419sabuaka@gmail.com>
Sat, 5 Sep 2020 12:19:39 +0000 (21:19 +0900)
committermk-linux419 <m.k419sabuaka@gmail.com>
Sat, 5 Sep 2020 12:19:39 +0000 (21:19 +0900)
channels/serene/airootfs/etc/skel/.config/autostart/genhome.desktop [new file with mode: 0644]
channels/serene/airootfs/etc/skel/.config/autostart/iso_boot_script.desktop [deleted file]
channels/serene/airootfs/etc/skel/.config/user-dirs.dirs [deleted file]
channels/serene/airootfs/etc/skel/.shortcat.sh [deleted file]
channels/serene/airootfs/root/customize_airootfs_serene.sh [deleted file]
channels/serene/airootfs/usr/bin/genhome [new file with mode: 0755]
channels/share/airootfs/root/customize_airootfs.sh [deleted file]
lubs
nfb/casper.conf [new file with mode: 0644]

diff --git a/channels/serene/airootfs/etc/skel/.config/autostart/genhome.desktop b/channels/serene/airootfs/etc/skel/.config/autostart/genhome.desktop
new file mode 100644 (file)
index 0000000..7ae8a4a
--- /dev/null
@@ -0,0 +1,13 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Name=genhome
+Comment=Generates home directories
+Icon=utilities-terminal
+Exec=/usr/bin/genhome
+X-GNOME-Autostart-enabled=true
+Type=Application
+RunHook=0
+StartupNotify=false
+Terminal=false
+Hidden=false
diff --git a/channels/serene/airootfs/etc/skel/.config/autostart/iso_boot_script.desktop b/channels/serene/airootfs/etc/skel/.config/autostart/iso_boot_script.desktop
deleted file mode 100644 (file)
index 1a18502..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-[Desktop Entry]
-Name=iso_boot_script
-GenericName=
-Icon=display
-Exec=/etc/bodhibuilder/isofiles/iso_boot_script.sh &
-Terminal=false
-Type=Application
-Categories=Settings;HardwareSettings;AudioVideo;Audio;Video;
-StartupNotify=true
diff --git a/channels/serene/airootfs/etc/skel/.config/user-dirs.dirs b/channels/serene/airootfs/etc/skel/.config/user-dirs.dirs
deleted file mode 100644 (file)
index 7f9a959..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-# This file is written by xdg-user-dirs-update
-# If you want to change or add directories, just edit the line you're
-# interested in. All local changes will be retained on the next run.
-# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped
-# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
-# absolute path. No other format is supported.
-# 
-XDG_DESKTOP_DIR="$HOME/Desktop"
-XDG_DOWNLOAD_DIR="$HOME/Downloads"
-XDG_TEMPLATES_DIR="$HOME/Templates"
-XDG_PUBLICSHARE_DIR="$HOME/Public"
-XDG_DOCUMENTS_DIR="$HOME/Documents"
-XDG_MUSIC_DIR="$HOME/Music"
-XDG_PICTURES_DIR="$HOME/Pictures"
-XDG_VIDEOS_DIR="$HOME/Videos"
diff --git a/channels/serene/airootfs/etc/skel/.shortcat.sh b/channels/serene/airootfs/etc/skel/.shortcat.sh
deleted file mode 100644 (file)
index 1da0878..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-a=$(cd $(dirname $0) && pwd) ; echo "file://$a/Documents/\nfile://$a/Downloads/\nfile://$a/Music/\nfile://$a/Pictures/\nfile://$a/Templates/\nfile://$a/Videos/">"$a/.config/gtk-3.0/bookmarks"
-rm ./.shortcat.sh
diff --git a/channels/serene/airootfs/root/customize_airootfs_serene.sh b/channels/serene/airootfs/root/customize_airootfs_serene.sh
deleted file mode 100644 (file)
index 9ec3d92..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env bash
-# SPDX-License-Identifier: GPL-3.0
-#
-# mk-linux419
-# Twitter: @fascoder_4
-# Email  : m.k419sabuaka@gmail.com
-#
-# Yamada Hayao
-# Twitter: @Hayao0819
-# Email  : hayao@fascode.net
-#
-# (c) 2019-2020 Fascode Network.
-#
-# customize_airootfs_serene.sh
-#
-
-set -e -u
-
-# Default value
-# All values can be changed by arguments.
-password="liveuser"
-username="liveuser"
-usershell="/bin/bash"
-debug=true
-
-
-# Parse arguments
-while getopts 'p:bt:k:rxju:o:i:s:da:' arg; do
-    case "${arg}" in
-        p) password="${OPTARG}" ;;
-        u) username="${OPTARG}" ;;
-        s) usershell="${OPTARG}" ;;
-        d) debug=true ;;
-        x) debug=true; set -xv ;;
-        a) arch="${OPTARG}"
-    esac
-done
-
-# Enable LightDM to auto login
-systemctl enable lightdm.service
-
-# Replace auto login user
-sed -i s/%USERNAME%/${username}/g /etc/lightdm/lightdm.conf
\ No newline at end of file
diff --git a/channels/serene/airootfs/usr/bin/genhome b/channels/serene/airootfs/usr/bin/genhome
new file mode 100755 (executable)
index 0000000..465c892
--- /dev/null
@@ -0,0 +1,52 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: GPL-3.0
+#
+# mk-linux419
+# Twitter: @fascoder_4
+# Email  : m.k419sabuaka@gmail.com
+#
+# (c) 2019-2020 Fascode Network.
+#
+# genhome
+#
+
+cd "${HOME}"
+
+if [[ ! -d "${HOME}/.config/gtk-3.0" ]]; then
+    mkdir -p "${HOME}/.config/gtk-3.0"
+fi
+
+if [[ -f "${HOME}/.config/user-dirs.dirs" ]]; then
+    rm -f "${HOME}/.config/user-dirs.dirs"
+fi
+
+if [[ -f "${HOME}/.config/user-dirs.locale" ]]; then
+    rm -f "${HOME}/.config/user-dirs.locale"
+fi
+
+xdg-user-dirs-update --force
+source "${HOME}/.config/user-dirs.dirs"
+
+cat <<EOF > "${HOME}/.config/gtk-3.0/bookmarks"
+file://${XDG_DOCUMENTS_DIR} ${XDG_DOCUMENTS_DIR##*/}
+file://${XDG_MUSIC_DIR} ${XDG_MUSIC_DIR##*/}
+file://${XDG_PICTURES_DIR} ${XDG_PICTURES_DIR##*/}
+file://${XDG_VIDEOS_DIR} ${XDG_VIDEOS_DIR##*/}
+file://${XDG_DOWNLOAD_DIR} ${XDG_DOWNLOAD_DIR##*/}
+EOF
+
+if [[ "$(cat ${HOME}/.config/user-dirs.locale)" != "en_US" ]] && [[ "$(cat ${HOME}/.config/user-dirs.locale)" != "C" ]]; then
+    for i in "Desktop" "Templates" "Documents" "Music" "Pictures" "Videos"; do
+        if [[ -d "${HOME}/${i}" ]]; then
+            cp -ar "${HOME}/${i}"/* "$(declare -p XDG_${i^^}_DIR | awk -F '"' '{print $2}')"
+            rm -rf "${HOME}/${i}"
+        fi
+    done
+
+    if [[ -d "${HOME}/Downloads" ]]; then
+        cp -ar "${HOME}/Downloads"/* "${XDG_DOWNLOAD_DIR}"
+        rm -rf "${HOME}/Downloads"
+    fi
+fi
+
+rm -f "${HOME}/.config/autostart/genhome.desktop"
\ No newline at end of file
diff --git a/channels/share/airootfs/root/customize_airootfs.sh b/channels/share/airootfs/root/customize_airootfs.sh
deleted file mode 100644 (file)
index 7c14fcb..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/usr/bin/env bash
-# SPDX-License-Identifier: GPL-3.0
-#
-# mk-linux419
-# Twitter: @fascoder_4
-# Email  : m.k419sabuaka@gmail.com
-#
-# Yamada Hayao
-# Twitter: @Hayao0819
-# Email  : hayao@fascode.net
-#
-# (c) 2019-2020 Fascode Network.
-#
-# customize_airootfs.sh
-#
-
-set -e
-
-# Default value
-# All values can be changed by arguments.
-
-password="liveuser"
-username="liveuser"
-usershell="/bin/bash"
-debug=true
-
-# Parse arguments
-while getopts 'p:u:s:dxa:' arg; do
-    case "${arg}" in
-        p) password="${OPTARG}" ;;
-        u) username="${OPTARG}" ;;
-        s) usershell="${OPTARG}" ;;
-        d) debug=true ;;
-        x) debug=true; set -xv ;;
-        a) arch="${OPTARG}"
-    esac
-done
-
-
-# Creating a root user.
-# usermod -s /usr/bin/zsh root
-function user_check () {
-if [[ $(getent passwd $1 > /dev/null ; printf $?) = 0 ]]; then
-    if [[ -z $1 ]]; then
-        echo -n "false"
-    fi
-    echo -n "true"
-else
-    echo -n "false"
-fi
-}
-
-if [[ $(user_check root) = false ]]; then
-    usermod -s "${usershell}" root
-    cp -aT /etc/skel/ /root/
-    chmod 700 /root
-    LC_ALL=C LANG=C xdg-user-dirs-update
-fi
-echo -e "${password}\n${password}" | passwd root
-
-# Allow sudo group to run sudo
-sed -i 's/^#\s*\(%sudo\s\+ALL=(ALL)\s\+ALL\)/\1/' /etc/sudoers
-
-# Create a user.
-# create_user <username> <password>
-function create_user () {
-    local _password
-    local _username
-
-    _username=${1}
-    _password=${2}
-
-    set +u
-    if [[ -z "${_username}" ]]; then
-        echo "User name is not specified." >&2
-        return 1
-    fi
-    if [[ -z "${_password}" ]]; then
-        echo "No password has been specified." >&2
-        return 1
-    fi
-    set -u
-
-    if [[ $(user_check ${_username}) = false ]]; then
-        useradd -m -s ${usershell} ${_username}
-        usermod -U -g ${_username} ${_username}
-        usermod -aG sudo ${_username}
-        cp -aT /etc/skel/ /home/${_username}/
-    fi
-    chmod 700 -R /home/${_username}
-    chown ${_username}:${_username} -R /home/${_username}
-    echo -e "${_password}\n${_password}" | passwd ${_username}
-    set -u
-}
-
-create_user "${username}" "${password}"
-
-
-# Set up auto login
-if [[ -f /etc/systemd/system/getty@tty1.service.d/autologin.conf ]]; then
-    sed -i s/%USERNAME%/"${username}"/g /etc/systemd/system/getty@tty1.service.d/autologin.conf
-fi
-
-
-# Set to execute calamares without password as alter user.
-cat >> /etc/sudoers << "EOF"
-Defaults pwfeedback
-EOF
-echo "${username} ALL=NOPASSWD: ALL" >> /etc/sudoers.d/alterlive
-
-
-# Chnage sudoers permission
-chmod 750 -R /etc/sudoers.d/
-chown root:root -R /etc/sudoers.d/
\ No newline at end of file
diff --git a/lubs b/lubs
index bbba485..f6d394e 100755 (executable)
--- a/lubs
+++ b/lubs
@@ -42,7 +42,6 @@ iso_filename="${iso_name}-${iso_version}-${arch}.iso"
 channel_name="serene"
 
 username="liveuser"
-password="liveuser"
 usershell="/bin/bash"
 
 debug=false
@@ -378,43 +377,10 @@ make_config() {
     run_cmd truncate -s 0 /etc/machine-id
 }
 
-make_customize_airootfs() {
-    #-- Overwrite airootfs files --#
-    local copy_airootfs
-
-    copy_airootfs() {
-        local _dir="${1%/}"
-
-        if [[ -d "${_dir}" ]]; then
-            cp -af "${_dir}"/* "${work_dir}/airootfs"
-        fi
-    }
-
-    copy_airootfs "${channels_dir}/share/airootfs"
-    copy_airootfs "${channels_dir}/${channel_name}/airootfs"
-
-    #-- Run scripts --#
-    local _customize_siript_options
-    _customize_siript_options="-a ${arch} -u ${username} -p ${password} -s ${usershell}"
-
-    #if ${bash_debug}; then
-    #    _customize_siript_options="$_customize_siript_options -x"
-    #elif ${debug}; then
-    if ${debug}; then
-        _customize_siript_options="$_customize_siript_options -d"
-    fi
-
-    # run_customize_script <script path from lubs> <script path in chroot>
-    local run_customize_script
-    run_customize_script() {
-        if [[ -f "${1}" ]]; then
-            chmod 755 "${1}"
-            run_cmd "${2}" "${_customize_siript_options}"
-        fi
-    }
-    
-    run_customize_script "${work_dir}/airootfs/root/customize_airootfs.sh" "/root/customize_airootfs.sh"
-    run_customize_script "${work_dir}/airootfs/root/customize_airootfs_${channel_name}.sh"  "/root/customize_airootfs_${channel_name}.sh"
+make_add_user() {
+    sed "s|%USERNAME%|${username}|g;s|%OS_NAME%|${os_name}|g" "${nfb_dir}/casper.conf" > "${work_dir}/airootfs/etc/casper.conf"
+    chmod 755 "${work_dir}"/airootfs/usr/share/initramfs-tools/scripts/casper-bottom/*adduser "${work_dir}"/airootfs/usr/share/initramfs-tools/scripts/casper-bottom/*autologin
+    run_cmd env -i bash -c 'mkinitramfs -o /boot/initrd.img-`uname -r` `uname -r`'
 }
 
 make_clean() {
@@ -670,7 +636,7 @@ run_once make_systemd
 run_once make_apt_packages
 #run_once make_snap_packages
 run_once make_config
-run_once make_customize_airootfs
+run_once make_add_user
 run_once make_clean
 run_once make_squashfs
 run_once make_nfb
diff --git a/nfb/casper.conf b/nfb/casper.conf
new file mode 100644 (file)
index 0000000..c4ebc7e
--- /dev/null
@@ -0,0 +1,8 @@
+# This file should go in /etc/casper.conf
+# Supported variables are:
+# USERNAME, USERFULLNAME, HOST, BUILD_SYSTEM
+export USERNAME="%USERNAME%"
+export USERFULLNAME="%USERNAME%"
+export HOST="%USERNAME%"
+export BUILD_SYSTEM="Ubuntu"
+export FLAVOUR="%OS_NAME%"
\ No newline at end of file