Browse Source

initial live services commit

pull/1/head
udeved 5 years ago
parent
commit
1ee0530226
  1. 88
      Makefile
  2. 63
      bin/cromnix-live.in
  3. 49
      data/99_zzz-portable-efi.in
  4. 18
      data/desktop.map
  5. 15
      data/grub2-portable-efi
  6. 67
      data/kbd-model.map
  7. 5
      data/live-session.desktop
  8. 28
      data/live.conf
  9. 16
      data/rc/cromnix-live.in
  10. 23
      data/rc/gnupg-mount.in
  11. 17
      data/rc/pacman-init.in
  12. 327
      lib/util-live.sh

88
Makefile

@ -0,0 +1,88 @@
Version=0.1
PREFIX = /usr/local
SYSCONFDIR = /etc
BIN = \
bin/cromnix-live
XBIN = \
bin/desktop-items \
bin/disable-dpms \
bin/pulseaudio-ctl-normal
LIBS = $(wildcard lib/*.sh)
SHARED = \
$(wildcard data/*.map) \
data/live.conf
RC = \
data/rc/gnupg-mount \
data/rc/pacman-init \
data/rc/cromnix-live
GRUB_DEFAULT = \
data/grub2-portable-efi
GRUB_D = \
data/99_zzz-portable-efi
all: $(BIN) $(RC) $(XBIN) ${GRUB_D}
edit = sed -e "s|@datadir[@]|$(DESTDIR)$(PREFIX)/share/artools|g" \
-e "s|@sysconfdir[@]|$(DESTDIR)$(SYSCONFDIR)/artools|g" \
-e "s|@libdir[@]|$(DESTDIR)$(PREFIX)/lib/artools|g"
%: %.in Makefile
@echo "GEN $@"
@$(RM) "$@"
@m4 -P $@.in | $(edit) >$@
@chmod a-w "$@"
@chmod +x "$@"
clean:
rm -f $(BIN) $(RC) $(XBIN) ${GRUB_D}
install_base:
install -dm0755 $(DESTDIR)$(PREFIX)/bin
install -m0755 ${BIN} $(DESTDIR)$(PREFIX)/bin
install -dm0755 $(DESTDIR)$(PREFIX)/lib/artools
install -m0644 ${LIBS} $(DESTDIR)$(PREFIX)/lib/artools
install -dm0755 $(DESTDIR)$(PREFIX)/share/artools
install -m0644 ${SHARED} $(DESTDIR)$(PREFIX)/share/artools
install_rc:
install -dm0755 $(DESTDIR)$(SYSCONFDIR)/init.d
install -m0755 ${RC} $(DESTDIR)$(SYSCONFDIR)/init.d
install_portable_efi:
install -dm0755 $(DESTDIR)$(SYSCONFDIR)/default
install -m0755 $(GRUB_DEFAULT) $(DESTDIR)$(SYSCONFDIR)/default
install -dm0755 $(DESTDIR)$(SYSCONFDIR)/grub.d
install -m0755 $(GRUB_D) $(DESTDIR)$(SYSCONFDIR)/grub.d
uninstall_base:
for f in ${BIN}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$f; done
for f in ${SHARED}; do rm -f $(DESTDIR)$(PREFIX)/share/artools/$$f; done
for f in ${LIBS}; do rm -f $(DESTDIR)$(PREFIX)/lib/artools/$$f; done
uninstall_portable_efi:
for f in ${GRUB_DEFAULT}; do rm -f $(DESTDIR)$(SYSCONFDIR)/default/$$f; done
for f in ${GRUB_D}; do rm -f $(DESTDIR)$(SYSCONFDIR)/grub.d/$$f; done
uninstall_rc:
for f in ${RC}; do rm -f $(DESTDIR)$(SYSCONFDIR)/init.d/$$f; done
install: install_base install_rc install_portable_efi
uninstall: uninstall_base uninstall_rc uninstall_portable_efi
dist:
git archive --format=tar --prefix=live-services-$(Version)/ $(Version) | gzip -9 > live-services-$(Version).tar.gz
gpg --detach-sign --use-agent live-services-$(Version).tar.gz
.PHONY: all clean install uninstall dist

63
bin/cromnix-live.in

@ -0,0 +1,63 @@
#!/bin/sh
LIBDIR='@libdir@'
DATADIR='@datadir@'
SYSCONFDIR='@sysconfdir@'
export LC_MESSAGES=C
export LANG=C
livetimer=$(date +%s%3N)
[[ -r ${LIBDIR}/util-live.sh ]] && source ${LIBDIR}/util-live.sh
load_live_config "${SYSCONFDIR}/live.conf" || load_live_config "${DATADIR}/live.conf"
livetimer=$(get_timer_ms)
detect_desktop_env
echo "Detected ${default_desktop_executable} ${default_desktop_file}: $(elapsed_time_ms ${livetimer})ms" >> /var/log/manjaro-live.log
livetimer=$(get_timer_ms)
CONSOLEFONT="$(kernel_cmdline vconsole.font)"
CONSOLEMAP="$(kernel_cmdline vconsole.font.map)"
arch=$(uname -m)
echo "Got consolefont and arch $arch: $(elapsed_time_ms ${livetimer})ms" >> /var/log/manjaro-live.log
# Activate swap
livetimer=$(get_timer_ms)
configure_swap
echo "Activated swap and added to fstab: $(elapsed_time_ms ${livetimer})ms" >> /var/log/manjaro-live.log
livetimer=$(get_timer_ms)
configure_language
echo "Finished localization: $(elapsed_time_ms ${livetimer})ms" >> /var/log/manjaro-live.log
livetimer=$(get_timer_ms)
configure_user
echo "Created user ${username} with password ${password}: $(elapsed_time_ms ${livetimer})ms" >> /var/log/manjaro-live.log
livetimer=$(get_timer_ms)
configure_sudoers_d
echo "Configured sudoers: $(elapsed_time_ms ${livetimer})ms" >> /var/log/manjaro-live.log
livetimer=$(get_timer_ms)
configure_machine_id
echo "Configured machine-id: $(elapsed_time_ms ${livetimer})ms" >> /var/log/manjaro-live.log
livetimer=$(get_timer_ms)
configure_accountsservice "${username}"
echo "Configured accountsservice: $(elapsed_time_ms ${livetimer})ms" >> /var/log/manjaro-live.log
livetimer=$(get_timer_ms)
configure_displaymanager
echo "Configured displaymanager: $(elapsed_time_ms ${livetimer})ms" >> /var/log/manjaro-live.log
livetimer=$(get_timer_ms)
configure_user_root /
echo "Configured root user: $(elapsed_time_ms ${livetimer})ms" >> /var/log/manjaro-live.log
if [[ -f /usr/bin/samba ]];then
livetimer=$(get_timer_ms)
configure_samba
echo "Configured samba: $(elapsed_time_ms ${livetimer})ms" >> /var/log/manjaro-live.log
fi

49
data/99_zzz-portable-efi.in

@ -0,0 +1,49 @@
#!/bin/sh
# grub-mkconfig helper script.
#
# Copyright © 2014 Niall Walsh <niallwalsh@celtux.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
set -e
MT_EFI_STANDALONE=""
MT_EFI_PORTABLE_PATH="/boot/efi/EFI/BOOT"
# override tool behaviour through /etc/default/grub2-fll-standalone
if [ -r /etc/default/grub2-portable-efi ]; then
. /etc/default/grub2-portable-efi
fi
patt='[[:space:]]-o[[:space:]]\+/boot/grub/grub.cfg'
# do nothing if disabled or grub-mkconfig is generating /boot/grub/grub.cfg
( [ "${MT_EFI_STANDALONE}" != "disable" ] && \
ps x | grep 'grub-mkconfig[[:space:]]' | grep -q -e "${patt}[[:space:]]" -e "${patt}$" ) || exit
beeb="${MT_EFI_PORTABLE_PATH}"
if [ -e "${beeb}" ]; then
# do not do anything to a beeb we didn't create
[ ! -e "${beeb}/fullstory" ] && exit
else
# create beeb and mark it as ours
mkdir -p "${beeb}"
touch "${beeb}/fullstory"
fi
for platform in i386-efi x86_64-efi ; do
filename="bootx64"
[ "${platform}" = "i386-efi" ] && filename="bootia32"
[ -e /usr/lib/grub/${platform} ] && grub-mkstandalone \
-o ${beeb}/${filename}.efi --compress=xz -O ${platform} \
/boot/grub/grub.cfg=/boot/grub/grub.cfg.new 2>&1 > /dev/null
done

18
data/desktop.map

@ -0,0 +1,18 @@
openbox:openbox-session
bspwm:bspwm-session
jwm:jwm
i3:i3
fluxbox:startfluxbox
pekwm:pekwm
plasma:startkde
gnome:gnome-session
xfce:startxfce4
cinnamon:cinnamon-session-cinnamon
mate:mate-session
enlightenment:enlightenment_start
LXDE:lxsession
lxqt:lxqt-session
pantheon:pantheon-session
budgie-desktop:budgie-desktop
deepin:startdde
Lumina-DE:start-lumina-desktop

15
data/grub2-portable-efi

@ -0,0 +1,15 @@
# Defaults for grub2-portable-efi update-grub helper
# sourced by grub2's update-grub
# installed at /etc/default/grub2-portable-efi by the maintainer scripts
#
# This is a POSIX shell fragment
#
# specify is this should be disabled (set to "disable")
# default:
#MT_EFI_STANDALONE=""
# specify where to install the portable efi
# default: /boot/efi/EFI/BOOT
#MT_EFI_PORTABLE_PATH="/boot/efi/EFI/BOOT"

67
data/kbd-model.map

@ -0,0 +1,67 @@
# Copied from systemd-localed
# http://cgit.freedesktop.org/systemd/systemd/log/src/locale/kbd-model-map
# (originally under LGPLv2.1+, used under the LGPL to GPL conversion clause)
# Generated from system-config-keyboard's model list
# consolelayout xlayout xmodel xvariant xoptions
sg ch pc105 de_nodeadkeys terminate:ctrl_alt_bksp
nl nl pc105 - terminate:ctrl_alt_bksp
mk-utf mk,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll
trq tr pc105 - terminate:ctrl_alt_bksp
uk gb pc105 - terminate:ctrl_alt_bksp
is-latin1 is pc105 - terminate:ctrl_alt_bksp
de de pc105 - terminate:ctrl_alt_bksp
la-latin1 latam pc105 - terminate:ctrl_alt_bksp
us us pc105+inet - terminate:ctrl_alt_bksp
ko kr pc105 - terminate:ctrl_alt_bksp
ro-std ro pc105 std terminate:ctrl_alt_bksp
de-latin1 de pc105 - terminate:ctrl_alt_bksp
slovene si pc105 - terminate:ctrl_alt_bksp
hu101 hu pc105 qwerty terminate:ctrl_alt_bksp
jp106 jp jp106 - terminate:ctrl_alt_bksp
croat hr pc105 - terminate:ctrl_alt_bksp
it2 it pc105 - terminate:ctrl_alt_bksp
hu hu pc105 - terminate:ctrl_alt_bksp
sr-latin rs pc105 latin terminate:ctrl_alt_bksp
fi fi pc105 - terminate:ctrl_alt_bksp
fr_CH ch pc105 fr terminate:ctrl_alt_bksp
dk-latin1 dk pc105 - terminate:ctrl_alt_bksp
fr fr pc105 - terminate:ctrl_alt_bksp
it it pc105 - terminate:ctrl_alt_bksp
ua-utf ua,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll
fr-latin1 fr pc105 - terminate:ctrl_alt_bksp
sg-latin1 ch pc105 de_nodeadkeys terminate:ctrl_alt_bksp
be-latin1 be pc105 - terminate:ctrl_alt_bksp
dk dk pc105 - terminate:ctrl_alt_bksp
fr-pc fr pc105 - terminate:ctrl_alt_bksp
bg_pho-utf8 bg,us pc105 ,phonetic terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll
it-ibm it pc105 - terminate:ctrl_alt_bksp
cz-us-qwertz cz,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll
br-abnt2 br abnt2 - terminate:ctrl_alt_bksp
ro ro pc105 - terminate:ctrl_alt_bksp
us-acentos us pc105 intl terminate:ctrl_alt_bksp
pt-latin1 pt pc105 - terminate:ctrl_alt_bksp
ro-std-cedilla ro pc105 std_cedilla terminate:ctrl_alt_bksp
tj_alt-UTF8 tj pc105 - terminate:ctrl_alt_bksp
de-latin1-nodeadkeys de pc105 nodeadkeys terminate:ctrl_alt_bksp
no no pc105 - terminate:ctrl_alt_bksp
bg_bds-utf8 bg,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll
dvorak us pc105 dvorak terminate:ctrl_alt_bksp
dvorak us pc105 dvorak-alt-intl terminate:ctrl_alt_bksp
ru ru,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll
cz-lat2 cz pc105 qwerty terminate:ctrl_alt_bksp
pl2 pl pc105 - terminate:ctrl_alt_bksp
es es pc105 - terminate:ctrl_alt_bksp
ro-cedilla ro pc105 cedilla terminate:ctrl_alt_bksp
ie ie pc105 - terminate:ctrl_alt_bksp
et ee pc105 - terminate:ctrl_alt_bksp
sk-qwerty sk pc105 - terminate:ctrl_alt_bksp,qwerty
fr-latin9 fr pc105 latin9 terminate:ctrl_alt_bksp
fr_CH-latin1 ch pc105 fr terminate:ctrl_alt_bksp
cf ca pc105 - terminate:ctrl_alt_bksp
sv-latin1 se pc105 - terminate:ctrl_alt_bksp
sr-cy rs pc105 - terminate:ctrl_alt_bksp
gr gr,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll
by by,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll
il il pc105 - terminate:ctrl_alt_bksp
kazakh kz,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll
lt lt pc105 - terminate:ctrl_alt_bksp

5
data/live-session.desktop

@ -0,0 +1,5 @@
[Desktop Entry]
Exec=desktop-items
Name=desktop-items
Comment=Live session desktop items
Type=Application

28
data/live.conf

@ -0,0 +1,28 @@
# live session configuration
# autologin
autologin=true
# login shell
login_shell=/bin/bash
# live username
username=manjaro
# live password
password=manjaro
# live group membership
addgroups='video,power,disk,storage,optical,network,lp,scanner,wheel'
# iso name
iso_name=manjaro
# default_desktop_file
default_desktop_file=lxqt
# default_desktop_executable
default_desktop_executable=lxqt-session
# samba workgroup
smb_workgroup=MANJARO

16
data/rc/cromnix-live.in

@ -0,0 +1,16 @@
#!/usr/bin/openrc-run
# Copyright 2014 Aaditya Bagga (aaditya_gnulinux@zoho.com)
# Distributed under the terms of the GNU General Public License v2
description="LiveMedia Config Script"
depend() {
need localmount
}
start() {
ebegin "Starting manjaro live script"
# run the manjaro live script
/usr/bin/manjaro-live
eend $?
}

23
data/rc/gnupg-mount.in

@ -0,0 +1,23 @@
#!/usr/bin/openrc-run
# Copyright 2015 artoo (flower_of_life@gmx.net)
# Distributed under the terms of the GNU General Public License v2
target_dir=/etc/pacman.d/gnupg
description="Temporary ${target_dir} directory"
depend() {
before pacman-init
}
start() {
ebegin "Mounting temporary gnupg directory"
[[ ! -d ${target_dir} ]] && mkdir -p ${target_dir}
mount -t tmpfs -o size=10M,mode=0755 tmpfs ${target_dir}
eend $?
}
stop(){
ebegin "Unmounting temporary gnupg directory"
umount -l ${target_dir}
eend $?
}

17
data/rc/pacman-init.in

@ -0,0 +1,17 @@
#!/usr/bin/openrc-run
# Copyright 2014 Aaditya Bagga (aaditya_gnulinux@zoho.com)
# Distributed under the terms of the GNU General Public License v2
description="Pacman initialization script"
depend() {
use net
need haveged gnupg-mount
}
start() {
ebegin "Running pacman initialization"
/usr/bin/pacman-key --init &> /dev/null
/usr/bin/pacman-key --populate archlinux manjaro &> /dev/null
eend $?
}

327
lib/util-live.sh

@ -0,0 +1,327 @@
#!/bin/bash
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
kernel_cmdline(){
for param in $(cat /proc/cmdline); do
case "${param}" in
$1=*) echo "${param##*=}"; return 0 ;;
$1) return 0 ;;
*) continue ;;
esac
done
[ -n "${2}" ] && echo "${2}"
return 1
}
get_lang(){
echo $(kernel_cmdline lang)
}
get_keytable(){
echo $(kernel_cmdline keytable)
}
get_tz(){
echo $(kernel_cmdline tz)
}
get_timer_ms(){
echo $(date +%s%3N)
}
# $1: start timer
elapsed_time_ms(){
echo $(echo $1 $(get_timer_ms) | awk '{ printf "%0.3f",($2-$1)/1000 }')
}
load_live_config(){
[[ -f $1 ]] || return 1
live_conf="$1"
[[ -r ${live_conf} ]] && source ${live_conf}
[[ -z ${autologin} ]] && autologin=true
[[ -z ${username} ]] && username="manjaro"
[[ -z ${password} ]] && password="manjaro"
[[ -z ${addgroups} ]] && addgroups=""
[[ -z ${login_shell} ]] && login_shell="/bin/bash"
[[ -z ${smb_workgroup} ]] && smb_workgroup="Manjaro"
echo "Loaded ${live_conf}: $(elapsed_time_ms ${livetimer})ms" >> /var/log/manjaro-live.log
return 0
}
is_valid_de(){
if [[ ${default_desktop_executable} != "none" ]] && \
[[ ${default_desktop_file} != "none" ]]; then
return 0
else
return 1
fi
}
load_desktop_map(){
local _space="s| ||g" _clean=':a;N;$!ba;s/\n/ /g' _com_rm="s|#.*||g" \
file=${DATADIR}/desktop.map
local desktop_map=$(sed "$_com_rm" "$file" \
| sed "$_space" \
| sed "$_clean")
echo ${desktop_map}
}
detect_desktop_env(){
local xs=/usr/share/xsessions ex=/usr/bin key val map=( $(load_desktop_map) )
default_desktop_file="none"
default_desktop_executable="none"
for item in "${map[@]}";do
key=${item%:*}
val=${item#*:}
if [[ -f $xs/$key.desktop ]] && [[ -f $ex/$val ]];then
default_desktop_file="$key"
default_desktop_executable="$val"
fi
done
}
configure_accountsservice(){
local path=/var/lib/AccountsService/users
if [ -d "${path}" ] ; then
echo "[User]" > ${path}/$1
echo "XSession=${default_desktop_file}" >> ${path}/$1
if [[ -f "/var/lib/AccountsService/icons/$1.png" ]];then
echo "Icon=/var/lib/AccountsService/icons/$1.png" >> ${path}/$1
fi
fi
}
set_lightdm_greeter(){
local greeters=$(ls /usr/share/xgreeters/*greeter.desktop) name
for g in ${greeters[@]};do
name=${g##*/}
name=${name%%.*}
case ${name} in
lightdm-gtk-greeter) break ;;
lightdm-*-greeter)
sed -i -e "s/^.*greeter-session=.*/greeter-session=${name}/" /etc/lightdm/lightdm.conf
;;
esac
done
}
set_lightdm_vt(){
sed -i -e 's/^.*minimum-vt=.*/minimum-vt=7/' /etc/lightdm/lightdm.conf
}
# set_sddm_elogind(){
# gpasswd -a sddm video &> /dev/null
# }
set_pam(){
for conf in /etc/pam.d/*;do
sed -e 's|systemd.so|elogind.so|g' -i $conf
done
}
configure_samba(){
local conf=/etc/samba/smb.conf
cp /etc/samba/smb.conf.default $conf
sed -e "s|^.*workgroup =.*|workgroup = ${smb_workgroup}|" -i $conf
}
configure_displaymanager(){
# Try to detect desktop environment
# Configure display manager
if [[ -f /usr/bin/lightdm ]];then
groupadd -r autologin
[[ -d /run/openrc ]] && set_lightdm_vt
set_lightdm_greeter
if $(is_valid_de); then
sed -i -e "s/^.*user-session=.*/user-session=$default_desktop_file/" /etc/lightdm/lightdm.conf
fi
if ${autologin};then
gpasswd -a ${username} autologin &> /dev/null
sed -i -e "s/^.*autologin-user=.*/autologin-user=${username}/" /etc/lightdm/lightdm.conf
sed -i -e "s/^.*autologin-user-timeout=.*/autologin-user-timeout=0/" /etc/lightdm/lightdm.conf
sed -i -e "s/^.*pam-autologin-service=.*/pam-autologin-service=lightdm-autologin/" /etc/lightdm/lightdm.conf
fi
elif [[ -f /usr/bin/gdm ]];then
configure_accountsservice "gdm"
if ${autologin};then
sed -i -e "s/\[daemon\]/\[daemon\]\nAutomaticLogin=${username}\nAutomaticLoginEnable=True/" /etc/gdm/custom.conf
fi
elif [[ -f /usr/bin/mdm ]];then
if $(is_valid_de); then
sed -i "s|default.desktop|$default_desktop_file.desktop|g" /etc/mdm/custom.conf
fi
elif [[ -f /usr/bin/sddm ]];then
if $(is_valid_de); then
sed -i -e "s|^Session=.*|Session=$default_desktop_file.desktop|" /etc/sddm.conf
fi
if ${autologin};then
sed -i -e "s|^User=.*|User=${username}|" /etc/sddm.conf
fi
elif [[ -f /usr/bin/lxdm ]];then
if $(is_valid_de); then
sed -i -e "s|^.*session=.*|session=/usr/bin/$default_desktop_executable|" /etc/lxdm/lxdm.conf
fi
if ${autologin};then
sed -i -e "s/^.*autologin=.*/autologin=${username}/" /etc/lxdm/lxdm.conf
fi
fi
[[ -d /run/openrc ]] && set_pam
}
gen_pw(){
echo $(perl -e 'print crypt($ARGV[0], "password")' ${password})
}
configure_user(){
# set up user and password
if [[ -n ${password} ]];then
useradd -m -G ${addgroups} -p $(gen_pw) -s ${login_shell} ${username}
else
useradd -m -G ${addgroups} -s ${login_shell} ${username}
fi
}
find_legacy_keymap(){
local file="${DATADIR}/kbd-model.map"
while read -r line || [[ -n $line ]]; do
if [[ -z $line ]] || [[ $line == \#* ]]; then
continue
fi
mapping=( $line ); # parses columns
if [[ ${#mapping[@]} != 5 ]]; then
continue
fi
if [[ "${keytable}" != "${mapping[0]}" ]]; then
continue
fi
if [[ "${mapping[3]}" = "-" ]]; then
mapping[3]=""
fi
X11_LAYOUT=${mapping[1]}
X11_MODEL=${mapping[2]}
X11_VARIANT=${mapping[3]}
x11_OPTIONS=${mapping[4]}
done < $file
}
write_x11_config(){
# find a x11 layout that matches the keymap
# in isolinux if you select a keyboard layout and a language that doesnt match this layout,
# it will provide the correct keymap, but not kblayout value
local X11_LAYOUT=
local X11_MODEL="pc105"
local X11_VARIANT=""
local X11_OPTIONS="terminate:ctrl_alt_bksp"
find_legacy_keymap
# layout not found, use KBLAYOUT
if [[ -z "$X11_LAYOUT" ]]; then
X11_LAYOUT="${keytable}"
fi
# create X11 keyboard layout config
mkdir -p "/etc/X11/xorg.conf.d"
local XORGKBLAYOUT="/etc/X11/xorg.conf.d/00-keyboard.conf"
echo "" >> "$XORGKBLAYOUT"
echo "Section \"InputClass\"" > "$XORGKBLAYOUT"
echo " Identifier \"system-keyboard\"" >> "$XORGKBLAYOUT"
echo " MatchIsKeyboard \"on\"" >> "$XORGKBLAYOUT"
echo " Option \"XkbLayout\" \"$X11_LAYOUT\"" >> "$XORGKBLAYOUT"
echo " Option \"XkbModel\" \"$X11_MODEL\"" >> "$XORGKBLAYOUT"
echo " Option \"XkbVariant\" \"$X11_VARIANT\"" >> "$XORGKBLAYOUT"
echo " Option \"XkbOptions\" \"$X11_OPTIONS\"" >> "$XORGKBLAYOUT"
echo "EndSection" >> "$XORGKBLAYOUT"
}
configure_language(){
# hack to be able to set the locale on bootup
local lang=$(get_lang)
keytable=$(get_keytable)
local timezone=$(get_tz)
# Fallback
# [[ -z "${lang}" ]] && lang="en_US"
# [[ -z "${keytable}" ]] && keytable="us"
# [[ -z "${timezone}" ]] && timezone="Etc/UTC"
sed -e "s/#${lang}.UTF-8/${lang}.UTF-8/" -i /etc/locale.gen
# echo "LANG=${lang}.UTF-8" >> /etc/environment
if [[ -d /run/openrc ]]; then
sed -i "s/keymap=.*/keymap=\"${keytable}\"/" /etc/conf.d/keymaps
fi
echo "KEYMAP=${keytable}" > /etc/vconsole.conf
echo "LANG=${lang}.UTF-8" > /etc/locale.conf
ln -sf /usr/share/zoneinfo/${timezone} /etc/localtime
write_x11_config
loadkeys "${keytable}"
locale-gen ${lang}
echo "Configured language: ${lang}" >> /var/log/manjaro-live.log
echo "Configured keymap: ${keytable}" >> /var/log/manjaro-live.log
echo "Configured timezone: ${timezone}" >> /var/log/manjaro-live.log
}
configure_machine_id(){
if [ -e "/etc/machine-id" ] ; then
# delete existing machine-id
echo "Deleting existing machine-id ..." >> /var/log/manjaro-live.log
rm /etc/machine-id
fi
# set unique machine-id
echo "Setting machine-id ..." >> /var/log/manjaro-live.log
dbus-uuidgen --ensure=/etc/machine-id
ln -sf /etc/machine-id /var/lib/dbus/machine-id
}
configure_sudoers_d(){
echo "%wheel ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/g_wheel
echo "root ALL=(ALL) ALL" > /etc/sudoers.d/u_root
#echo "${username} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/u_live
}
configure_swap(){
local swapdev="$(fdisk -l 2>/dev/null | grep swap | cut -d' ' -f1)"
if [ -e "${swapdev}" ]; then
swapon ${swapdev}
fi
}
configure_user_root(){
# set up root password
echo "root:${password}" | chroot $1 chpasswd
cp /etc/skel/.{bash_profile,bashrc,bash_logout} /root/
[[ -f /etc/skel/.extend.bashrc ]] && cp /etc/skel/.extend.bashrc /root/
[[ -f /etc/skel/.gtkrc-2.0 ]] && cp /etc/skel/.gtkrc-2.0 /root/
if [[ -d /etc/skel/.config ]]; then
cp -a /etc/skel/.config /root/
fi
}
Loading…
Cancel
Save