first commit

This commit is contained in:
2026-01-31 01:03:40 +01:00
commit 8ffeb37bd4
31 changed files with 1022 additions and 0 deletions

116
Makefile Normal file
View File

@@ -0,0 +1,116 @@
Version=17.0
PREFIX = /usr/local
SYSCONFDIR = /etc
BIN = \
bin/manjaro-live \
bin/mhwd-live \
bin/mhwd-live-net
XBIN = \
bin/desktop-items \
bin/disable-dpms \
bin/pulseaudio-ctl-normal
XDG = $(wildcard data/*.desktop)
LIBS = $(wildcard lib/*.sh)
SHARED = \
$(wildcard data/*.map) \
data/live.conf
RC = \
data/rc/gnupg-mount \
data/rc/mhwd-live-net \
data/rc/mirrors-live-net \
data/rc/pacman-init \
data/rc/manjaro-live \
data/rc/mhwd-live \
data/rc/mirrors-live
SD = $(wildcard data/sd/*)
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/manjaro-tools|g" \
-e "s|@sysconfdir[@]|$(DESTDIR)$(SYSCONFDIR)/manjaro-tools|g" \
-e "s|@libdir[@]|$(DESTDIR)$(PREFIX)/lib/manjaro-tools|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/manjaro-tools
install -m0644 ${LIBS} $(DESTDIR)$(PREFIX)/lib/manjaro-tools
install -dm0755 $(DESTDIR)$(PREFIX)/share/manjaro-tools
install -m0644 ${SHARED} $(DESTDIR)$(PREFIX)/share/manjaro-tools
install_rc:
install -dm0755 $(DESTDIR)$(SYSCONFDIR)/init.d
install -m0755 ${RC} $(DESTDIR)$(SYSCONFDIR)/init.d
install_sd:
install -dm0755 $(DESTDIR)$(PREFIX)/lib/systemd/system
install -m0644 ${SD} $(DESTDIR)$(PREFIX)/lib/systemd/system
install_xdg:
install -dm0755 $(DESTDIR)$(PREFIX)/bin
install -m0755 ${XBIN} $(DESTDIR)$(PREFIX)/bin
install -dm0755 $(DESTDIR)$(SYSCONFDIR)/skel/.config/autostart
install -m0755 ${XDG} $(DESTDIR)$(SYSCONFDIR)/skel/.config/autostart
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/manjaro-tools/$$f; done
for f in ${LIBS}; do rm -f $(DESTDIR)$(PREFIX)/lib/manjaro-tools/$$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
uninstall_sd:
for f in ${SD}; do rm -f $(DESTDIR)$(PREFIX)/lib/systemd/system/$$f; done
uninstall_xdg:
for f in ${XBIN}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$f; done
for f in ${XDG}; do rm -f $(DESTDIR)$(SYSCONFDIR)/skel/.config/autostart/$$f; done
install: install_base install_rc install_sd install_xdg install_portable_efi
uninstall: uninstall_base uninstall_rc uninstall_sd uninstall_xdg uninstall_portable_efi
dist:
git archive --format=tar --prefix=manjaro-tools-livecd-$(Version)/ $(Version) | gzip -9 > manjaro-tools-livecd-$(Version).tar.gz
gpg --detach-sign --use-agent manjaro-tools-livecd-$(Version).tar.gz
.PHONY: all clean install uninstall dist

4
README.md Normal file
View File

@@ -0,0 +1,4 @@
manjaro-tools-livecd
====================
System services for Manjaro's live session

44
bin/desktop-items.in Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/sh
xdg=$(xdg-user-dir DESKTOP)
src='/usr/share/applications'
if [[ -f /usr/bin/calamares ]]; then
install -Dm755 $src/calamares.desktop \
$xdg/calamares.desktop
if $(is_sonar); then
sed -e "s/^.*Name=.*/Name=Install Sonar Linux (Calamares)/" -i $xdg/calamares.desktop
fi
fi
if [[ -f /usr/bin/manjaro-architect ]]; then
install -Dm755 $src/manjaro-architect.desktop \
$xdg/manjaro-architect.desktop
# workaround for mate-terminal; https://github.com/manjaro/desktop-settings/issues/120
if [[ $DESKTOP_SESSION == "mate" ]]; then
sed -i "s/^Exec.*/Exec=mate-terminal -e 'sudo \/usr\/bin\/setup'/; s/Terminal.*/Terminal=false/" $xdg/manjaro-architect.desktop
fi
fi
if [[ -f "$src/manjaro-documentation.desktop" ]]; then
install -Dm755 $src/manjaro-documentation.desktop \
"$xdg/manjaro-documentation.desktop"
fi
if [[ -f "$src/hexchat.desktop" ]]; then
install -Dm755 $src/hexchat.desktop \
"$xdg/hexchat.desktop"
fi
# workaround for glib trash bug (https://bugzilla.gnome.org/show_bug.cgi?id=748248)
userid=$(id -u $USER)
if [ ! -d "/.Trash-$userid" ]; then
sudo mkdir -p /.Trash-$userid/{expunged,files,info}
sudo chown -R $userid /.Trash-$userid
fi
# mark launchers trusted for XFCE 4.18
for f in $(ls $xdg/*desktop); do
gio set -t string $f metadata::xfce-exe-checksum "$(sha256sum $f | awk '{print $1}')"
done;

6
bin/disable-dpms.in Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
## DPMS - Display Power Management Settings
## These are disabled by default to prevent auto-actions when
## the system is idle, such as screen blanking (10 mins) or
## suspending (1 hour).
(sleep 15s && xset -dpms; xset s off) &

66
bin/manjaro-live.in Executable file
View File

@@ -0,0 +1,66 @@
#!/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
### DECIDE IF WE DON'T NEED IT ###
# see also https://github.com/calamares/calamares/issues/860
# 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

10
bin/mhwd-live-net.in Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/sh
[[ -r @libdir@/util-live.sh ]] && source @libdir@/util-live.sh
DRIVER="$(kernel_cmdline driver nonfree)"
MODULES_DIR='/etc/calamares/modules'
echo "Setting MHWD driver: ${DRIVER} ..." >> /var/log/mhwd-live.log
sed -e "s|^.*driver:.*|driver: ${DRIVER}|" -i "${MODULES_DIR}/mhwdcfg.conf"
echo "MHWD DONE" >> /var/log/mhwd-live.log

40
bin/mhwd-live.in Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/sh
[[ -r @libdir@/util-live.sh ]] && source @libdir@/util-live.sh
DRIVER="$(kernel_cmdline driver nonfree)"
VIDEO="$(kernel_cmdline xdriver no)"
REPO_PATH='/opt/mhwd'
PAC_CONF="${REPO_PATH}/pacman-mhwd.conf"
# In a live session we should never have a database lock at boot, this is a bug!
# In the past pamac caused issues about that.
# Fixed here: https://github.com/manjaro/manjaro-tools/commit/57a039088ae4485bc5dc411e36a90c0753e670f1
seconds="0"
while [ -e "/var/lib/pacman/db.lck" ];
do
echo 'Pacman is not ready yet. Will try again in 10 seconds.' >> /var/log/mhwd-live.log
echo '----' >> /var/log/mhwd-live.log
ps -ef >> /var/log/mhwd-live.log
echo '----' >> /var/log/mhwd-live.log
seconds=$(($seconds + 10))
sleep 10
if [[ "$seconds" == "30" ]]; then
echo 'Warning: removing pacman db.lck!' >> /var/log/mhwd-live.log
rm /var/lib/pacman/db.lck
fi
done
# hwdetect_graphics
if [[ -e "${PAC_CONF}" ]]; then
MODULES_DIR='/etc/calamares/modules'
echo "Running MHWD..." >> /var/log/mhwd-live.log
sed -e "s|^.*driver:.*|driver: ${DRIVER}|" -i "${MODULES_DIR}/mhwdcfg.conf"
if [[ "${VIDEO}" == "vesa" ]]; then
mhwd --install pci video-vesa --pmconfig "${PAC_CONF}" >> /var/log/mhwd-live.log
else
mhwd --auto pci ${DRIVER} 0300 --pmconfig "${PAC_CONF}" >> /var/log/mhwd-live.log
fi
echo "MHWD DONE" >> /var/log/mhwd-live.log
fi

6
bin/pulseaudio-ctl-normal.in Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
# Do we need this at all?
if [ -e /usr/bin/pulseaudio-ctl ];then
(sleep 10s && /usr/bin/pulseaudio-ctl set 70) &
fi

49
data/99_zzz-portable-efi.in Executable file
View File

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

21
data/desktop.map Normal file
View File

@@ -0,0 +1,21 @@
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
awesome:awesome
ukui:ukui-session
cutefish-xsession:cutefish-session

View File

@@ -0,0 +1,9 @@
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=disable dpms
Comment=Disable DPMS in Live-Session
Exec=disable-dpms
StartupNotify=false
Terminal=false
Hidden=false

15
data/grub2-portable-efi Normal file
View File

@@ -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 Normal file
View File

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

View File

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

28
data/live.conf Normal file
View File

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

View File

@@ -0,0 +1,10 @@
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=pulseaudio-ctl
Comment=Set Volume to 70%
Exec=pulseaudio-ctl-normal
StartupNotify=false
Terminal=false
Hidden=false

23
data/rc/gnupg-mount.in Executable file
View File

@@ -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 $?
}

16
data/rc/manjaro-live.in Executable file
View File

@@ -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 $?
}

16
data/rc/mhwd-live-net.in Executable file
View File

@@ -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
depend() {
need manjaro-live
before xdm
after pacman-init
}
start() {
ebegin "Running mhwd-live script"
# run the mhwd script
/usr/bin/mhwd-live-net &> /dev/null
eend $?
}

18
data/rc/mhwd-live.in Executable file
View File

@@ -0,0 +1,18 @@
#!/usr/bin/openrc-run
# Copyright 2014 Aaditya Bagga (aaditya_gnulinux@zoho.com)
# Distributed under the terms of the GNU General Public License v2
#description="Manjaro livecd mhwd-live script"
depend() {
need manjaro-live
before xdm
after pacman-init
}
start() {
ebegin "Running mhwd-live script"
# run the mhwd script
/usr/bin/mhwd-live &> /dev/null
eend $?
}

View File

@@ -0,0 +1,15 @@
#!/usr/bin/openrc-run
# Copyright 2016 artoo (artoo@manjaro.org)
# Distributed under the terms of the GNU General Public License v2
description="Pacman mirror ranking"
depend() {
need net
}
start() {
ebegin "Running mirrors ranking"
/usr/bin/pacman-mirrors -f 5
eend $?
}

15
data/rc/mirrors-live.in Normal file
View File

@@ -0,0 +1,15 @@
#!/usr/bin/openrc-run
# Copyright 2016 artoo (artoo@manjaro.org)
# Distributed under the terms of the GNU General Public License v2
description="Pacman mirror ranking"
depend() {
need net
}
start() {
ebegin "Running mirrors randomizer"
/usr/bin/pacman-mirrors -f 5
eend $?
}

17
data/rc/pacman-init.in Executable file
View File

@@ -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 $?
}

View File

@@ -0,0 +1,8 @@
[Unit]
Description=Temporary /etc/pacman.d/gnupg directory
[Mount]
What=tmpfs
Where=/etc/pacman.d/gnupg
Type=tmpfs
Options=mode=0755

View File

@@ -0,0 +1,10 @@
[Unit]
Description=LiveMedia Config Script
Before=systemd-user-sessions.service
[Service]
Type=oneshot
ExecStart=/usr/bin/manjaro-live
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,10 @@
[Unit]
Description=LiveMedia MHWD net Script
Before=systemd-user-sessions.service
[Service]
Type=oneshot
ExecStart=/usr/bin/mhwd-live-net
[Install]
WantedBy=multi-user.target

10
data/sd/mhwd-live.service Normal file
View File

@@ -0,0 +1,10 @@
[Unit]
Description=LiveMedia MHWD Script
Before=systemd-user-sessions.service
[Service]
Type=oneshot
ExecStart=/usr/bin/mhwd-live
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,11 @@
[Unit]
Description=LiveMedia Pacman mirrors ranking script
Wants=network-online.target
After=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/pacman-mirrors -f 5
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,10 @@
[Unit]
Description=LiveMedia Pacman mirror ranking script
Before=systemd-user-sessions.service
[Service]
Type=oneshot
ExecStart=/usr/bin/pacman-mirrors -f 5
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,15 @@
[Unit]
Description=Initialize Pacman keyring
Wants=haveged.service
After=haveged.service
Requires=etc-pacman.d-gnupg.mount
After=etc-pacman.d-gnupg.mount
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/pacman-key --init
ExecStart=/usr/bin/pacman-key --populate archlinux manjaro mabox
[Install]
WantedBy=multi-user.target

332
lib/util-live.sh Normal file
View File

@@ -0,0 +1,332 @@
#!/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=file:///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 [[ -e /etc/sddm.conf.d/kde_settings.conf ]];then
conf_file=/etc/sddm.conf.d/kde_settings.conf
else
conf_file=/etc/sddm.conf
fi
if $(is_valid_de); then
sed -i -e "s|^Session=.*|Session=$default_desktop_file.desktop|" $conf_file
fi
if ${autologin};then
sed -i -e "s|^User=.*|User=${username}|" $conf_file
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 $(openssl passwd -6 ${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 -an /etc/skel/.config /root/
fi
}