12 Commits

Author SHA1 Message Date
a1c122c058 Merge pull request 'add initial support for dinit' (#10) from konimex/live-services:master into master
Reviewed-on: artix/live-services#10
2021-11-05 16:34:25 +01:00
bea63084ab add initial support for dinit 2021-10-27 17:02:51 +07:00
83b9a674a8 0.11.2 2021-10-20 14:10:14 +03:00
26ffee5d7c Merge pull request 'fix suite66 pdf' (#9) from nous/live-services:master into master
Reviewed-on: artix/live-services#9
2021-10-20 13:01:51 +02:00
8c3a81d0ee fix suite66 pdf 2021-10-20 13:00:23 +02:00
91b23a5265 remove archlinux keyring 2021-07-12 00:05:56 +02:00
aa58c995eb Add haveged depends 2021-05-03 01:18:36 +02:00
68b91bc6ec Merge pull request 'Add 66 to Makefile' (#8) from ndowens/live-services:master into master
Reviewed-on: artix/live-services#8
2021-04-30 01:33:15 +02:00
e3c3b5d9a5 Add 66 to Makefile 2021-04-29 17:33:08 -05:00
edaf1d8c0b Merge pull request 'Add 66 services' (#7) from ndowens/live-services:master into master
Reviewed-on: artix/live-services#7
2021-04-30 00:05:48 +02:00
3d97503604 Add 66 services 2021-04-29 17:01:33 -05:00
e9e2ec9d9e live (#6)
set service paths via make

use more make vars

fix session & desktop detection

move liveuser declare

shellcheck

update sysusers

make the live user configurable with make

cleanup log

properly copy user skel

create live home

add sysusers file

refactor

v0.10

update live.conf

artix-live: remove some config

use m4_include()

Reviewed-on: artix/live-services#6
Co-Authored-By: artoo <artoo@artixlinux.org>
Co-Committed-By: artoo <artoo@artixlinux.org>
2021-01-08 19:48:44 +01:00
25 changed files with 272 additions and 191 deletions

View File

@@ -1,6 +1,6 @@
BSD 2-Clause License BSD 2-Clause License
Copyright (c) 2018-2019, Artix Linux Copyright (c) 2018-2021, Artix Linux
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without

View File

@@ -1,4 +1,4 @@
VERSION = 0.8 VERSION = 0.11.2
PKG = live-services PKG = live-services
TOOLS = artools TOOLS = artools
@@ -8,6 +8,8 @@ PREFIX ?= /usr
BINDIR = $(PREFIX)/bin BINDIR = $(PREFIX)/bin
LIBDIR = $(PREFIX)/lib LIBDIR = $(PREFIX)/lib
DATADIR = $(PREFIX)/share DATADIR = $(PREFIX)/share
SYSUSERSDIR = $(PREFIX)/lib/sysusers.d
LIVEUSER ?= artix
FMODE = -m0644 FMODE = -m0644
DMODE = -dm0755 DMODE = -dm0755
@@ -16,8 +18,6 @@ BMODE = -m0755
BIN = \ BIN = \
bin/artix-live bin/artix-live
LIBS = $(wildcard lib/*.sh)
SHARED = \ SHARED = \
$(wildcard data/*.map) \ $(wildcard data/*.map) \
data/live.conf data/live.conf
@@ -34,28 +34,70 @@ RUNIT_SV = \
data/runit/pacman-init.run data/runit/pacman-init.run
S6_LIVE = \ S6_LIVE = \
$(wildcard data/s6/artix-live/*) data/s6/artix-live/up \
data/s6/artix-live/type
S6_PI = \ S6_PI = \
$(wildcard data/s6/pacman-init/*) data/s6/pacman-init/type \
data/s6/pacman-init/up \
data/s6/pacman-init/down
S6_BUNDLE = \ S6_BUNDLE = \
$(wildcard data/s6/live/*) data/s6/live/type \
data/s6/live/contents
S6_SV = \ 66_LIVE = \
data/s6/pacman-init.run data/66/artix-live
66_PI = \
data/66/pacman-init
DINIT_LIVE = \
data/dinit/artix-live
DINIT_PI = \
data/dinit/pacman-init
DINIT_PI_SCRIPT = \
data/dinit/pacman-init.script
XDG = $(wildcard data/*.desktop) XDG = $(wildcard data/*.desktop)
XBIN = bin/desktop-items XBIN = bin/desktop-items
SYSUSERS = \
data/sysusers
RM = rm -f
M4 = m4 -P
CHMODAW = chmod a-w
CHMODX = chmod +x
all: $(BIN) $(SYSUSERS) $(XBIN) $(RC) $(RUNIT_SVD) $(S6_PI) $(S6_LIVE)
EDIT = sed -e "s|@datadir[@]|$(DATADIR)|g" \
-e "s|@sysconfdir[@]|$(SYSCONFDIR)|g" \
-e "s|@bindir[@]|$(BINDIR)|g" \
-e "s|@libdir[@]|$(LIBDIR)|g" \
-e "s|@live[@]|$(LIVEUSER)|g"
%: %.in Makefile lib/util-live.sh
@echo "GEN $@"
@$(RM) "$@"
@{ echo -n 'm4_changequote([[[,]]])'; cat $@.in; } | $(M4) | $(EDIT) >$@
@$(CHMODAW) "$@"
@$(CHMODX) "$@"
@bash -O extglob -n "$@"
clean:
$(RM) $(BIN) $(SYSUSERS) $(XBIN) $(RC) $(RUNIT_SVD) $(S6_PI) $(S6_LIVE)
install_base: install_base:
install $(DMODE) $(DESTDIR)$(BINDIR) install $(DMODE) $(DESTDIR)$(BINDIR)
install $(BMODE) $(BIN) $(DESTDIR)$(BINDIR) install $(BMODE) $(BIN) $(DESTDIR)$(BINDIR)
install $(DMODE) $(DESTDIR)$(LIBDIR)/$(TOOLS) install $(DMODE) $(DESTDIR)$(SYSUSERSDIR)
install $(FMODE) $(LIBS) $(DESTDIR)$(LIBDIR)/$(TOOLS) install $(FMODE) $(SYSUSERS) $(DESTDIR)$(SYSUSERSDIR)/live-artix.conf
install $(DMODE) $(DESTDIR)$(DATADIR)/$(TOOLS) install $(DMODE) $(DESTDIR)$(DATADIR)/$(TOOLS)
install $(FMODE) $(SHARED) $(DESTDIR)$(DATADIR)/$(TOOLS) install $(FMODE) $(SHARED) $(DESTDIR)$(DATADIR)/$(TOOLS)
@@ -86,6 +128,21 @@ install_s6:
install $(DMODE) $(DESTDIR)$(SYSCONFDIR)/s6/sv/live install $(DMODE) $(DESTDIR)$(SYSCONFDIR)/s6/sv/live
install $(BMODE) $(S6_BUNDLE) $(DESTDIR)$(SYSCONFDIR)/s6/sv/live/ install $(BMODE) $(S6_BUNDLE) $(DESTDIR)$(SYSCONFDIR)/s6/sv/live/
install_66:
install $(DMODE) $(DESTDIR)$(SYSCONFDIR)/66/service
install $(FMODE) $(66_LIVE) $(DESTDIR)$(SYSCONFDIR)/66/service/artix-live
install $(FMODE) $(66_PI) $(DESTDIR)$(SYSCONFDIR)/66/service/pacman-init
install_dinit:
install $(DMODE) $(DESTDIR)$(SYSCONFDIR)/dinit.d/scripts
install $(DMODE) $(DESTDIR)$(SYSCONFDIR)/dinit.d/boot.d
install $(FMODE) $(DINIT_LIVE) $(DESTDIR)$(SYSCONFDIR)/dinit.d/artix-live
install $(FMODE) $(DINIT_PI) $(DESTDIR)$(SYSCONFDIR)/dinit.d/pacman-init
install $(BMODE) $(DINIT_PI_SCRIPT) $(DESTDIR)$(SYSCONFDIR)/dinit.d/scripts/pacman-init
ln -s ../artix-live $(DESTDIR)$(SYSCONFDIR)/dinit.d/boot.d
ln -s ../pacman-init $(DESTDIR)$(SYSCONFDIR)/dinit.d/boot.d
install_xdg: install_xdg:
install -dm0755 $(DESTDIR)$(PREFIX)/bin install -dm0755 $(DESTDIR)$(PREFIX)/bin
install -m0755 ${XBIN} $(DESTDIR)$(PREFIX)/bin install -m0755 ${XBIN} $(DESTDIR)$(PREFIX)/bin

View File

@@ -1,36 +0,0 @@
#!/bin/sh
LOGFILE='/var/log/artix-live.log'
. /usr/lib/artools/util-live.sh
load_live_config "/etc/artools/live.conf" || load_live_config "/usr/share/artools/live.conf"
CONSOLEFONT="$(kernel_cmdline vconsole.font)"
CONSOLEMAP="$(kernel_cmdline vconsole.font.map)"
echo "Got consolefont ${CONSOLEFONT} and consolemap ${CONSOLEMAP}" >> "${LOGFILE}"
# Activate swap
configure_swap
echo "Activated swap and added to fstab" >> "${LOGFILE}"
configure_language
echo "Finished localization" >> "${LOGFILE}"
configure_user 'root'
echo "Configured root user" >> "${LOGFILE}"
configure_user "${USER_NAME}"
echo "Created user ${USER_NAME} with password ${PASSWORD}" >> "${LOGFILE}"
detect_desktop_env
echo "Detected ${DEFAULT_DESKTOP_EXECUTABLE} ${DEFAULT_DESKTOP_FILE}" >> "${LOGFILE}"
configure_accountsservice "${USER_NAME}"
echo "Configured accountsservice" >> "${LOGFILE}"
configure_displaymanager
echo "Configured displaymanager" >> "${LOGFILE}"
configure_branding
echo "Configured branding" >> "${LOGFILE}"

23
bin/artix-live.in Normal file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
m4_include(lib/util-live.sh)
LOGFILE='/var/log/artix-live.log'
CONSOLEFONT="$(kernel_cmdline vconsole.font)"
CONSOLEMAP="$(kernel_cmdline vconsole.font.map)"
#echo "Got consolefont ${CONSOLEFONT} and consolemap ${CONSOLEMAP}" >> "${LOGFILE}"
configure_swap
configure_language
configure_user
detect_desktop_env
configure_accountsservice
configure_displaymanager
configure_branding

View File

@@ -5,20 +5,20 @@
xdg-user-dirs-update --force xdg-user-dirs-update --force
xdg=$(xdg-user-dir DESKTOP) xdg=$(xdg-user-dir DESKTOP)
src=/usr/share/applications src=@datadir@/applications
# if [[ -f $src/org.kde.konversation.desktop ]]; then # if [[ -f $src/org.kde.konversation.desktop ]]; then
# install -m644 $src/org.kde.konversation.desktop \ # install -m644 $src/org.kde.konversation.desktop \
# $xdg/org.kde.konversation.desktop # $xdg/org.kde.konversation.desktop
# fi # fi
if [[ -f /usr/bin/calamares ]]; then if [[ -f @bindir@/calamares ]]; then
cp -f $src/calamares.desktop "$xdg/" cp -f $src/calamares.desktop "$xdg/"
sed -i s/Icon.*=calamares/Icon=artixlinux-logo/g "$xdg"/calamares.desktop sed -i s/Icon.*=calamares/Icon=artixlinux-logo/g "$xdg"/calamares.desktop
chmod +x "$xdg/calamares.desktop" chmod +x "$xdg/calamares.desktop"
fi fi
docs=/usr/share/doc/artix docs=@datadir@/doc/artix
for f in {Configuration,Troubleshooting}.pdf; do for f in {Configuration,Troubleshooting}.pdf; do
ln -s $docs/$f "$xdg"/$f ln -s $docs/$f "$xdg"/$f
@@ -28,6 +28,8 @@ if [[ -d /run/openrc ]]; then
ln -s $docs/OpenRC.pdf "$xdg"/OpenRC.pdf ln -s $docs/OpenRC.pdf "$xdg"/OpenRC.pdf
elif [[ -d /run/runit ]]; then elif [[ -d /run/runit ]]; then
ln -s $docs/Runit.pdf "$xdg"/Runit.pdf ln -s $docs/Runit.pdf "$xdg"/Runit.pdf
elif [[ -d /run/66 ]]; then
ln -s $docs/Suite66.pdf "$xdg"/Suite66.pdf
else else
ln -s $docs/S6.pdf "$xdg"/S6.pdf ln -s $docs/S6.pdf "$xdg"/S6.pdf
fi fi

8
data/66/artix-live Normal file
View File

@@ -0,0 +1,8 @@
[main]
@type = oneshot
@version = 0.0.1
@description = "artix-live service"
@user = ( root )
[start]
@execute = (artix-live)

14
data/66/pacman-init Normal file
View File

@@ -0,0 +1,14 @@
[main]
@type = oneshot
@description = "pacman init service"
@version = 0.0.2
@user = ( root )
@extdepends = ( haveged )
[start]
@execute = (
foreground { mkdir -p /etc/pacman.d/gnupg }
foreground { mount -t tmpfs -o size=10M,mode=0755 tmpfs /etc/pacman.d/gnupg }
fdmove -c 2 1
foreground { pacman-key --init }
foreground { pacman-key --populate artix } )

View File

@@ -7,7 +7,7 @@ pekwm:pekwm
enlightenment:enlightenment_start enlightenment:enlightenment_start
Lumina-DE:start-lumina-desktop Lumina-DE:start-lumina-desktop
LXDE:lxsession LXDE:lxsession
plasma:startkde plasma:startplasma-x11
lxqt:lxqt-session lxqt:lxqt-session
pantheon:pantheon-session pantheon:pantheon-session
budgie-desktop:budgie-desktop budgie-desktop:budgie-desktop

4
data/dinit/artix-live Normal file
View File

@@ -0,0 +1,4 @@
type = scripted
command = /usr/bin/artix-live
restart = false
waits-for = setup

5
data/dinit/pacman-init Normal file
View File

@@ -0,0 +1,5 @@
type = scripted
command = /etc/dinit.d/scripts/pacman-init
stop-command = /usr/bin/umount -l /etc/pacman.d/gnupg
restart = false
waits-for = setup

View File

@@ -0,0 +1,4 @@
#!/bin/sh
/usr/bin/mount -t tmpfs -o size=10M,mode=0755 tmpfs /etc/pacman.d/gnupg
/usr/bin/pacman-key --init
/usr/bin/pacman-key --populate artix

View File

@@ -3,11 +3,5 @@
# autologin # autologin
AUTOLOGIN=true AUTOLOGIN=true
# live username
USER_NAME=artix
# live password # live password
PASSWORD=artix PASSWORD=artix
# live group membership
ADDGROUPS='video,power,cdrom,network,lp,scanner,wheel'

View File

@@ -12,6 +12,6 @@ depend() {
start() { start() {
ebegin "Running pacman initialization" ebegin "Running pacman initialization"
/usr/bin/pacman-key --init &> /dev/null /usr/bin/pacman-key --init &> /dev/null
/usr/bin/pacman-key --populate archlinux artix &> /dev/null /usr/bin/pacman-key --populate artix &> /dev/null
eend $? eend $?
} }

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
. /usr/lib/rc/functions . @libdir@/rc/functions
case "$1" in case "$1" in
start) start)

View File

@@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
mount -t tmpfs -o size=10M,mode=0755 tmpfs /etc/pacman.d/gnupg mount -t tmpfs -o size=10M,mode=0755 tmpfs /etc/pacman.d/gnupg
pacman-key --init 1>&2 pacman-key --init 1>&2
pacman-key --populate archlinux artix 1>&2 pacman-key --populate artix 1>&2
exec chpst -b pacman-init pause exec chpst -b pacman-init pause

View File

@@ -1,3 +0,0 @@
#!/usr/bin/execlineb -P
if { echo "Initializing artix live system" }
foreground { /usr/bin/artix-live }

2
data/s6/artix-live/up.in Normal file
View File

@@ -0,0 +1,2 @@
#!@bindir@/execlineb -P
exec @bindir@/artix-live

View File

@@ -1,2 +1,2 @@
#!/usr/bin/execline -P #!@bindir@/execlineb -P
umount -l /etc/pacman.d/gnupg umount -l /etc/pacman.d/gnupg

View File

@@ -1,6 +1,6 @@
#!/usr/bin/execlineb -P #!@bindir@/execlineb -P
foreground { mkdir -p /etc/pacman.d/gnupg } foreground { mkdir -p /etc/pacman.d/gnupg }
foreground { mount -t tmpfs -o size=10M,mode=0755 tmpfs /etc/pacman.d/gnupg } foreground { mount -t tmpfs -o size=10M,mode=0755 tmpfs /etc/pacman.d/gnupg }
fdmove -c 2 1 fdmove -c 2 1
foreground { pacman-key --init } foreground { pacman-key --init }
foreground { pacman-key --populate archlinux artix } foreground { pacman-key --populate artix }

12
data/sysusers.in Normal file
View File

@@ -0,0 +1,12 @@
# artix live user
u @live@ 1000 - /home/@live@ /bin/bash
m @live@ video
m @live@ power
m @live@ cdrom
m @live@ network
m @live@ lp
m @live@ scanner
m @live@ wheel
m @live@ log
m @live@ users

View File

@@ -1,22 +1,15 @@
#!/bin/bash #!/hint/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.
export LC_MESSAGES=C export LC_MESSAGES=C
export LANG=C export LANG=C
# {{{ functions
kernel_cmdline(){ kernel_cmdline(){
for param in $(cat /proc/cmdline); do for param in $(cat /proc/cmdline); do
case "${param}" in case "${param}" in
$1=*) echo "${param##*=}"; return 0 ;; $1=*) echo "${param##*=}"; return 0 ;;
$1) return 0 ;; "$1") return 0 ;;
*) continue ;; *) continue ;;
esac esac
done done
@@ -25,86 +18,63 @@ kernel_cmdline(){
} }
get_lang(){ get_lang(){
echo $(kernel_cmdline lang) kernel_cmdline lang
} }
get_keytable(){ get_keytable(){
echo $(kernel_cmdline keytable) kernel_cmdline keytable
} }
get_tz(){ get_tz(){
echo $(kernel_cmdline tz) kernel_cmdline tz
}
load_live_config(){
[[ -f $1 ]] || return 1
local live_conf="$1"
[[ -r ${live_conf} ]] && source ${live_conf}
AUTOLOGIN=${AUTOLOGIN:-true}
USER_NAME=${USER_NAME:-"artix"}
PASSWORD=${PASSWORD:-"artix"}
ADDGROUPS=${ADDGROUPS:-"video,power,cdrom,network,lp,scanner,wheel,users,log"}
return 0
} }
is_valid_de(){ is_valid_de(){
if [[ ${DEFAULT_DESKTOP_EXECUTABLE} != "none" ]] && \ if [[ ${DEFAULT_DESKTOP_EXECUTABLE} != "none" ]] && \
[[ ${DEFAULT_DESKTOP_FILE} != "none" ]]; then [[ ${DEFAULT_DESKTOP_FILE} != "none" ]]; then
return 0 return 0
else
return 1
fi fi
} return 1
load_desktop_map(){
local _space="s| ||g" _clean=':a;N;$!ba;s/\n/ /g' _com_rm="s|#.*||g" \
file=/usr/share/artools/desktop.map
local desktop_map=$(sed "$_com_rm" "$file" | sed "$_space" | sed "$_clean")
echo ${desktop_map}
} }
detect_desktop_env(){ detect_desktop_env(){
local key val map=( $(load_desktop_map) ) local key val map
map="${DATADIR}"/artools/desktop.map
DEFAULT_DESKTOP_FILE="none" DEFAULT_DESKTOP_FILE="none"
DEFAULT_DESKTOP_EXECUTABLE="none" DEFAULT_DESKTOP_EXECUTABLE="none"
for item in "${map[@]}";do while read -r item; do
key=${item%:*} key=${item%:*}
val=${item#*:} val=${item#*:}
if [[ -f /usr/share/xsessions/$key.desktop ]] && [[ -f /usr/bin/$val ]];then if [[ -f "${DATADIR}"/xsessions/$key.desktop ]] && [[ -f ${BINDIR}/$val ]];then
DEFAULT_DESKTOP_FILE="$key" DEFAULT_DESKTOP_FILE="$key"
DEFAULT_DESKTOP_EXECUTABLE="$val" DEFAULT_DESKTOP_EXECUTABLE="$val"
fi fi
done done < "$map"
echo "Detected ${DEFAULT_DESKTOP_EXECUTABLE} ${DEFAULT_DESKTOP_FILE}" >> "${LOGFILE}"
} }
configure_accountsservice(){ configure_accountsservice(){
local path=/var/lib/AccountsService/users local path=/var/lib/AccountsService/users user="${1:-${LIVEUSER}}"
if [ -d "${path}" ] ; then if [ -d "${path}" ] ; then
echo "[User]" > ${path}/$1 echo "[User]" > ${path}/"$user"
echo "XSession=${DEFAULT_DESKTOP_FILE}" >> ${path}/$1 echo "XSession=${DEFAULT_DESKTOP_FILE}" >> ${path}/"$user"
if [[ -f "/var/lib/AccountsService/icons/$1.png" ]];then if [[ -f "/var/lib/AccountsService/icons/$user.png" ]];then
echo "Icon=/var/lib/AccountsService/icons/$1.png" >> ${path}/$1 echo "Icon=/var/lib/AccountsService/icons/$user.png" >> ${path}/"$user"
fi fi
fi fi
echo "Configured accountsservice" >> "${LOGFILE}"
} }
set_lightdm_greeter(){ set_lightdm_greeter(){
local greeters=$(ls /usr/share/xgreeters/*greeter.desktop) name local name
for g in ${greeters[@]};do for g in "${DATADIR}"/xgreeters/*.desktop;do
name=${g##*/} name=${g##*/}
name=${name%%.*} name=${name%%.*}
case ${name} in case ${name} in
lightdm-gtk-greeter) break ;; lightdm-gtk-greeter) break ;;
lightdm-*-greeter) lightdm-*-greeter)
sed -i -e "s/^.*greeter-session=.*/greeter-session=${name}/" /etc/lightdm/lightdm.conf sed -e "s/^.*greeter-session=.*/greeter-session=${name}/" \
-i /etc/lightdm/lightdm.conf
;; ;;
esac esac
done done
@@ -113,53 +83,50 @@ configure_accountsservice(){
configure_displaymanager(){ configure_displaymanager(){
# Try to detect desktop environment # Try to detect desktop environment
# Configure display manager # Configure display manager
if [[ -f /usr/bin/lightdm ]];then
groupadd -r autologin
sed -i -e 's/^.*minimum-vt=.*/minimum-vt=7/' /etc/lightdm/lightdm.conf
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 ${USER_NAME} autologin &> /dev/null
sed -i -e "s/^.*autologin-user=.*/autologin-user=${USER_NAME}/" /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=${USER_NAME}\nAutomaticLoginEnable=True/" /etc/gdm/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=${USER_NAME}|" /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=${USER_NAME}/" /etc/lxdm/lxdm.conf
fi
fi
}
gen_pw(){ if [[ -f "${BINDIR}"/lightdm ]];then
echo $(perl -e 'print crypt($ARGV[0], "password")' ${PASSWORD}) groupadd -r autologin
gpasswd -a "${LIVEUSER}" autologin &> /dev/null
set_lightdm_greeter
if is_valid_de; then
sed -e "s/^.*user-session=.*/user-session=$DEFAULT_DESKTOP_FILE/" \
-e 's/^.*minimum-vt=.*/minimum-vt=7/' \
-i /etc/lightdm/lightdm.conf
fi
${AUTOLOGIN} && sed -e "s/^.*autologin-user=.*/autologin-user=${LIVEUSER}/" \
-e "s/^.*autologin-user-timeout=.*/autologin-user-timeout=0/" \
-e "s/^.*pam-autologin-service=.*/pam-autologin-service=lightdm-autologin/" \
-i /etc/lightdm/lightdm.conf
elif [[ -f "${BINDIR}"/gdm ]];then
configure_accountsservice "gdm"
${AUTOLOGIN} && sed -e "s/\[daemon\]/\[daemon\]\nAutomaticLogin=${LIVEUSER}\nAutomaticLoginEnable=True/" \
-i /etc/gdm/custom.conf
elif [[ -f "${BINDIR}"/sddm ]];then
if is_valid_de; then
sed -e "s|^Session=.*|Session=$DEFAULT_DESKTOP_FILE.desktop|" \
-i /etc/sddm.conf
fi
${AUTOLOGIN} && sed -e "s|^User=.*|User=${LIVEUSER}|" \
-i /etc/sddm.conf
elif [[ -f "${BINDIR}"/lxdm ]];then
if is_valid_de; then
sed -e "s|^.*session=.*|session=${BINDIR}/${DEFAULT_DESKTOP_EXECUTABLE}|" \
-i /etc/lxdm/lxdm.conf
fi
${AUTOLOGIN} && sed -e "s/^.*autologin=.*/autologin=${LIVEUSER}/" \
-i /etc/lxdm/lxdm.conf
fi
echo "Configured displaymanager" >> "${LOGFILE}"
} }
find_legacy_keymap(){ find_legacy_keymap(){
local file="/usr/share/artools/kbd-model.map" kt="$1" local file="${DATADIR}/artools/kbd-model.map" kt="$1"
while read -r line || [[ -n $line ]]; do while read -r line || [[ -n $line ]]; do
if [[ -z $line ]] || [[ $line == \#* ]]; then if [[ -z $line ]] || [[ $line == \#* ]]; then
continue continue
fi fi
local mapping=( $line ); # parses columns local mapping=( "$line" ); # parses columns
if [[ ${#mapping[@]} != 5 ]]; then if [[ ${#mapping[@]} != 5 ]]; then
continue continue
fi fi
@@ -175,7 +142,7 @@ find_legacy_keymap(){
X11_LAYOUT=${mapping[1]} X11_LAYOUT=${mapping[1]}
X11_MODEL=${mapping[2]} X11_MODEL=${mapping[2]}
X11_VARIANT=${mapping[3]} X11_VARIANT=${mapping[3]}
x11_OPTIONS=${mapping[4]} X11_OPTIONS=${mapping[4]}
done < $file done < $file
} }
@@ -201,64 +168,92 @@ write_x11_config(){
local XORGKBLAYOUT="/etc/X11/xorg.conf.d/00-keyboard.conf" local XORGKBLAYOUT="/etc/X11/xorg.conf.d/00-keyboard.conf"
echo "" >> "$XORGKBLAYOUT"
echo "Section \"InputClass\"" > "$XORGKBLAYOUT" echo "Section \"InputClass\"" > "$XORGKBLAYOUT"
echo " Identifier \"system-keyboard\"" >> "$XORGKBLAYOUT" {
echo " MatchIsKeyboard \"on\"" >> "$XORGKBLAYOUT" echo " Identifier \"system-keyboard\""
echo " Option \"XkbLayout\" \"$X11_LAYOUT\"" >> "$XORGKBLAYOUT" echo " MatchIsKeyboard \"on\""
echo " Option \"XkbModel\" \"$X11_MODEL\"" >> "$XORGKBLAYOUT" echo " Option \"XkbLayout\" \"$X11_LAYOUT\""
echo " Option \"XkbVariant\" \"$X11_VARIANT\"" >> "$XORGKBLAYOUT" echo " Option \"XkbModel\" \"$X11_MODEL\""
echo " Option \"XkbOptions\" \"$X11_OPTIONS\"" >> "$XORGKBLAYOUT" echo " Option \"XkbVariant\" \"$X11_VARIANT\""
echo "EndSection" >> "$XORGKBLAYOUT" echo " Option \"XkbOptions\" \"$X11_OPTIONS\""
echo "EndSection"
} >> "$XORGKBLAYOUT"
} }
configure_language(){ configure_language(){
# hack to be able to set the locale on bootup # hack to be able to set the locale on bootup
local lang=$(get_lang) local lang keytable timezone
local keytable=$(get_keytable) lang=$(get_lang)
local timezone=$(get_tz) keytable=$(get_keytable)
timezone=$(get_tz)
sed -e "s/#${lang}.UTF-8/${lang}.UTF-8/" -i /etc/locale.gen sed -e "s/#${lang}.UTF-8/${lang}.UTF-8/" -i /etc/locale.gen
if [[ -d /run/openrc ]]; then
sed -i "s/keymap=.*/keymap=\"${keytable}\"/" /etc/conf.d/keymaps
fi
echo "KEYMAP=${keytable}" > /etc/vconsole.conf echo "KEYMAP=${keytable}" > /etc/vconsole.conf
echo "LANG=${lang}.UTF-8" > /etc/locale.conf echo "LANG=${lang}.UTF-8" > /etc/locale.conf
ln -sf /usr/share/zoneinfo/${timezone} /etc/localtime ln -sf "${DATADIR}"/zoneinfo/"${timezone}" /etc/localtime
write_x11_config "${keytable}" write_x11_config "${keytable}"
loadkeys "${keytable}" loadkeys "${keytable}"
locale-gen ${lang} locale-gen "${lang}"
echo "Configured language: ${lang}" >> "${LOGFILE}" {
echo "Configured keymap: ${keytable}" >> "${LOGFILE}" echo "Configured language: ${lang}"
echo "Configured timezone: ${timezone}" >> "${LOGFILE}" echo "Configured keymap: ${keytable}"
echo "Configured timezone: ${timezone}"
echo "Finished localization"
} >> "${LOGFILE}"
} }
configure_swap(){ configure_swap(){
local swapdev="$(fdisk -l 2>/dev/null | grep swap | cut -d' ' -f1)" local swapdev
swapdev="$(fdisk -l 2>/dev/null | grep swap | cut -d' ' -f1)"
if [ -e "${swapdev}" ]; then if [ -e "${swapdev}" ]; then
swapon ${swapdev} swapon "${swapdev}"
fi fi
echo "Activated swap and added to fstab" >> "${LOGFILE}"
} }
configure_branding(){ configure_branding(){
if [[ -f /usr/bin/neofetch ]]; then if [[ -f "${BINDIR}"/neofetch ]]; then
neofetch >| /etc/issue neofetch >| /etc/issue
echo "Configured branding" >> "${LOGFILE}"
fi fi
} }
configure_user(){ configure_user(){
local user="$1" echo "root:${PASSWORD}" | chroot / chpasswd
if [[ "$user" == 'root' ]];then cp /etc/skel/.{bash_profile,bashrc,bash_logout} /root/
echo "root:${PASSWORD}" | chroot / chpasswd
cp /etc/skel/.{bash_profile,bashrc,bash_logout} /root/ mkdir /home/${LIVEUSER}
else chown ${LIVEUSER}:${LIVEUSER} /home/${LIVEUSER}
local args=(-m -G ${ADDGROUPS} -s /bin/bash $user) echo "${LIVEUSER}:${PASSWORD}" | chroot / chpasswd
# set up user and password cp -r /etc/skel/.[^.]* /home/${LIVEUSER}
[[ -n ${PASSWORD} ]] && args+=(-p $(gen_pw)) chown -R ${LIVEUSER}:${LIVEUSER} /home/${LIVEUSER}
useradd "${args[@]}" echo "Configured live user ${LIVEUSER} with password ${PASSWORD}" >> "${LOGFILE}"
fi
} }
# }}}
load_live_config(){
[[ -f $1 ]] || return 1
local live_conf="$1"
[[ -r "${live_conf}" ]] && source "${live_conf}"
AUTOLOGIN=${AUTOLOGIN:-true}
PASSWORD=${PASSWORD:-artix}
return 0
}
load_live_config "@sysconfdir@/artools/live.conf" || load_live_config "@datadir@/artools/live.conf"
LIVEUSER=@live@
DATADIR=@datadir@
BINDIR=@bindir@