From 312eebfe440b8208a58515eee12954a6f9dbf7db Mon Sep 17 00:00:00 2001 From: obarun <eric@obarun.org> Date: Tue, 26 May 2020 19:01:23 +1100 Subject: [PATCH] Bump v0.3.0 --- .gitignore | 2 +- INSTALL.md | 23 +++ LICENSE | 2 +- Makefile | 55 +++++ NEWS | 14 -- NEWS.md | 25 +++ configure | 193 ++++++++++++++++++ module/boot-user@/.configure/.xsession | 12 -- module/boot-user@/.configure/configure | 21 -- module/boot-user@/.configure/help | 78 ------- module/boot-user@/All-@M | 5 - .../{.configure => configure}/.xinitrc | 11 +- module/boot-user@/configure/.xsession | 12 ++ module/boot-user@/configure/configure | 90 ++++++++ module/boot-user@/env-@M/setenv-@M | 67 ------ module/boot-user@/mount-@M/mount-run-@M | 17 -- module/boot-user@/scandir-@M | 18 -- module/boot-user@/service@/mount-run@ | 19 ++ package/info | 3 + package/modes | 1 + package/targets.mak | 9 + scripts/66-mods.sh | 109 ---------- service/boot-user@ | 38 ++++ tools/install.sh | 64 ++++++ 24 files changed, 538 insertions(+), 350 deletions(-) create mode 100644 INSTALL.md create mode 100644 Makefile delete mode 100644 NEWS create mode 100644 NEWS.md create mode 100755 configure delete mode 100755 module/boot-user@/.configure/.xsession delete mode 100755 module/boot-user@/.configure/configure delete mode 100644 module/boot-user@/.configure/help delete mode 100644 module/boot-user@/All-@M rename module/boot-user@/{.configure => configure}/.xinitrc (69%) create mode 100755 module/boot-user@/configure/.xsession create mode 100755 module/boot-user@/configure/configure delete mode 100644 module/boot-user@/env-@M/setenv-@M delete mode 100644 module/boot-user@/mount-@M/mount-run-@M delete mode 100644 module/boot-user@/scandir-@M create mode 100644 module/boot-user@/service@/mount-run@ create mode 100644 package/info create mode 100644 package/modes create mode 100644 package/targets.mak delete mode 100755 scripts/66-mods.sh create mode 100644 service/boot-user@ create mode 100755 tools/install.sh diff --git a/.gitignore b/.gitignore index 12718aa..8b13789 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -*-66mod/ + diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..691d0f2 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,23 @@ +Build Instructions +------------------ + +## Requirements + +- GNU make version 3.81 or later + +This software will install on any operating system that implements POSIX.1-2008, available at [opengroup](http://pubs.opengroup.org/onlinepubs/9699919799/). + +## Standard usage + +`./configure && make && sudo make install` will work for most users. + +## Customization + +You can customize paths via flags given to configure. See `./configure --help` for a list of all available configure options. + +## Runtime dependencies + +- 66-tools version 0.0.4.0 or later https://framagit.org/Obarun/66-tools/ +- scandir-66serv version 0.1.0 or later https://framagit.org/pkg/obmods/scandir-66erv +- console-tracker-66serv version 0.1.0 or later https://framagit.org/pkg/obmods/console-tracker-66serv +- display-manager-66serv version 0.1.0 or later https://framagit.org/pkg/obmods/display-manager-66serv diff --git a/LICENSE b/LICENSE index 0f5927e..6826876 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2019 Eric Vidal <eric@obarun.org> +Copyright (c) 2015-2020 Eric Vidal <eric@obarun.org> All rights reserved. Permission to use, copy, modify, and/or distribute this software for any diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..91b8d03 --- /dev/null +++ b/Makefile @@ -0,0 +1,55 @@ +# +# This Makefile requires GNU make. +# +# Do not make changes here. +# Use the included .mak files. +# + +make_need := 3.81 +ifeq "" "$(strip $(filter $(make_need), $(firstword $(sort $(make_need) $(MAKE_VERSION)))))" +fail := $(error Your make ($(MAKE_VERSION)) is too old. You need $(make_need) or newer) +endif + +-include config.mak +include package/targets.mak + +INSTALL := ./tools/install.sh + +install: install-script install-service install-service-module install-service-instance-module install-configure +install-script: $(SCRIPT_TARGET:module/boot-user@/configure/%=$(DESTDIR)$(module_directory)/boot-user@/configure/%) +install-service: $(SERVICE_TARGET:service/%=$(DESTDIR)$(service_directory)/%) +install-service-module: $(MODULE_TARGET:module/boot-user@/service/%=$(DESTDIR)$(module_directory)/boot-user@/service/%) +install-service-instance-module: $(MODULE_INSTANCE_TARGET:module/boot-user@/service@/%=$(DESTDIR)$(module_directory)/boot-user@/service@/%) +install-configure: $(MODULE_CONFIGURE_TARGET:module/boot-user@/configure/configure=$(DESTDIR)$(module_directory)/boot-user@/configure/configure) + + +$(DESTDIR)$(module_directory)/boot-user@/configure/%: module/boot-user@/configure/% + exec $(INSTALL) -D -m 755 $< $@ + sed -i -e 's,@BINDIR@,$(bindir),' $@ + +$(DESTDIR)$(module_directory)/boot-user@/configure/configure: module/boot-user@/configure/configure + exec $(INSTALL) -D -m 755 $< $@ + sed -i -e 's,@BINDIR@,$(bindir),' $@ + +$(DESTDIR)$(module_directory)/boot-user@/service/%: module/boot-user@/service/% + exec $(INSTALL) -D -m 644 $< $@ + +$(DESTDIR)$(module_directory)/boot-user@/service@/%: module/boot-user@/service@/% + exec $(INSTALL) -D -m 644 $< $@ + + + +$(DESTDIR)$(service_directory)/%: service/% + exec $(INSTALL) -D -m 644 $< $@ + sed -i -e 's,@VERSION@,$(version),' \ + -e "s,@DISPLAY_MANAGER@,$(DISPLAY_MANAGER)," \ + -e "s,@CONSOLE_TRACKER@,$(CONSOLE_TRACKER)," \ + -e "s,@XDG_RUNTIME@,$(XDG_RUNTIME)," \ + -e "s,@DESKTOP_CMDLINE@,$(DESKTOP_CMDLINE)," $@ + +version: + @echo $(version) + +.PHONY: install version + +.DELETE_ON_ERROR: diff --git a/NEWS b/NEWS deleted file mode 100644 index 2ec5b46..0000000 --- a/NEWS +++ /dev/null @@ -1,14 +0,0 @@ -Changelog for boot-user-66mod - -In 0.2.1 --------- - - -Bugs fix - -In 0.1.0 ----------- - - Bugs fix. - -In 0.0.1 ----------- - - first commit. diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..0cc8a2e --- /dev/null +++ b/NEWS.md @@ -0,0 +1,25 @@ +# Changelog for boot-user-66serv + +--- + +# In 0.3.0 + +- Pass to new module format + +--- + +# In 0.2.1 + +-Bugs fix + +--- + +# In 0.1.0 + +- Bugs fix. + +--- + +# In 0.0.1 + +- first commit. diff --git a/configure b/configure new file mode 100755 index 0000000..9ebc148 --- /dev/null +++ b/configure @@ -0,0 +1,193 @@ +#!/bin/sh + +. package/info + +usage () { +cat <<EOF +Usage: $0 [OPTION]... [TARGET] + +Defaults for the options are specified in brackets. + +Installation directories: + --prefix=PREFIX main installation prefix [/] + --exec-prefix=EPREFIX installation prefix for executable files [PREFIX] + +Fine tuning of the installation directories: + --bindir=BINDIR user executables [EPREFIX/bin] + --datarootdir=DATAROOTDIR read-only architecture-independent data root [PREFIX/share] + --with-system-service=DIR 66 service intallation directory [DATAROOTDIR/$package_macro_dir/service] + --with-system-module=DIR 66 module intallation directory [DATAROOTDIR/$package_macro_dir/module] + +Fine tunning of boot-user configuration: + --DISPLAY_MANAGER=VALUE display manager to use [] + --CONSOLE_TRACKER=VALUE console tracker to use [] + --XDG_RUNTIME=BOOLEAN create and mount the XDG_RUNTIME directory [!yes] + --DESKTOP_CMDLINE=VALUE commandline to use in the .xinitrc file [!jwm] + + Use yes or no with lowercase character to set BOOLEAN values. + + Empty value is a commented one and not used at all. + + An exclamation mark '!' at the begin of the value unexport the variable + for the environment after the use. This is avoid to poluate the environment + with tempory variables. You need to single-quote the options as + follow: + ./configure --XDG_RUNTIME='!yes' + +EOF +exit 0 +} + +# Helper functions + +# If your system does not have printf, you can comment this, but it is +# generally not a good idea to use echo. +# See http://www.etalabs.net/sh_tricks.html +echo () { + IFS=" " + printf %s\\n "$*" +} + +quote () { + tr '\n' ' ' <<EOF | grep '^[-[:alnum:]_=,./:]* $' >/dev/null 2>&1 && { echo "$1" ; return 0 ; } +$1 +EOF + echo "$1" | sed -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/" -e "s#^'\([-[:alnum:]_,./:]*\)=\(.*\)\$#\1='\2#" -e "s|\*/|* /|g" +} + +fail () { + echo "$*" + exit 1 +} + +fnmatch () { + eval "case \"\$2\" in $1) return 0 ;; *) return 1 ;; esac" +} + +cmdexists () { + type "$1" >/dev/null 2>&1 +} + +stripdir () { + while eval "fnmatch '*/' \"\${$1}\"" ; do + eval "$1=\${$1%/}" + done +} + +testval () { + if test -z ${1}; then + return 0 ; + else + return 1 ; + fi +} + +# Actual script + +prefix= +exec_prefix='$prefix' +bindir='$exec_prefix/bin' +datarootdir='$prefix/share' +service_directory='$datarootdir/$package_macro_dir/service' +module_directory='$datarootdir/$package_macro_dir/module' +DISPLAY_MANAGER= +CONSOLE_TRACKER= +XDG_RUNTIME='!yes' +DESKTOP_CMDLINE='!jwm' + +for arg ; do + case "$arg" in + --help) usage ;; + --prefix=*) prefix=${arg#*=} ;; + --exec-prefix=*) exec_prefix=${arg#*=} ;; + --bindir=*) bindir=${arg#*=} ;; + --datarootdir=*) datarootdir=${arg#*=} ;; + --with-system-service=*) service_directory=${arg#*=} ;; + --with-system-module=*) module_directory=${arg#*=} ;; + --DISPLAY_MANAGER=*) DISPLAY_MANAGER=${arg#*=} ;; + --CONSOLE_TRACKER=*) CONSOLE_TRACKER=${arg#*=} ;; + --XDG_RUNTIME=*) XDG_RUNTIME=${arg#*=} ;; + --DESKTOP_CMDLINE=*) DESKTOP_CMDLINE=${arg#*=} ;; + -* ) echo "$0: unknown option $arg" ;; + *=*) ;; + *) target=$arg ;; + esac +done + +# Add /usr in the default case +if test -z "$prefix" ; then + if test "$datarootdir" = '$prefix/share'; then + datarootdir=/usr/share + fi +fi + +# Expand installation directories +stripdir prefix +for i in exec_prefix bindir datarootdir \ + service_directory module_directory ; do + eval tmp=\${$i} + eval $i=$tmp + stripdir $i +done + +stripdir datarootdir +for i in service_directory module_directory; do + eval tmp=\${$i} + eval $i=$tmp + stripdir $i +done + +for i in DISPLAY_MANAGER CONSOLE_TRACKER XDG_RUNTIME DESKTOP_CMDLINE; do + eval tmp=\${$i} + if testval $tmp; then + if [ "${i}" = "DISPLAY_MANAGER" ]; then + eval $i='${i}=\"\\#${i}=sddm\"' + elif [ "${i}" = "CONSOLE_TRACKER" ]; then + eval $i='${i}=\"\\#${i}=consolekit\"' + else + eval $i='${i}=\"\\#${i}=\"' + fi + else + eval $i='$i=$i=$tmp' + fi +done + +# Get usable temp filenames +i=0 +set -C +while : ; do + i=$(($i+1)) + tmpc="./tmp-configure-$$-$PPID-$i.c" + tmpe="./tmp-configure-$$-$PPID-$i.tmp" + 2>|/dev/null > "$tmpc" && break + 2>|/dev/null > "$tmpe" && break + test "$i" -gt 50 && fail "$0: cannot create temporary files" +done +set +C +trap 'rm -f "$tmpc" "$tmpe"' EXIT ABRT INT QUIT TERM HUP + +echo "creating config.mak..." +cmdline=$(quote "$0") +for i ; do cmdline="$cmdline $(quote "$i")" ; done +exec 3>&1 1>config.mak +cat << EOF +# This file was generated by: +# $cmdline +# Any changes made here will be lost if configure is re-run. + +version := $version +prefix := $prefix +exec_prefix := $exec_prefix +bindir := $bindir +datarootdir := $datarootdir +service_directory := $service_directory +module_directory := $module_directory +package_macro_dir := $package_macro_dir +$DISPLAY_MANAGER +$CONSOLE_TRACKER +$XDG_RUNTIME +$DESKTOP_CMDLINE +EOF + +exec 1>&3 3>&- +echo " ... done." diff --git a/module/boot-user@/.configure/.xsession b/module/boot-user@/.configure/.xsession deleted file mode 100755 index 0620112..0000000 --- a/module/boot-user@/.configure/.xsession +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/bash - -list=( $(ls -1 ${HOME}/.66/conf/boot-user) ) -for i in ${list[@]};do - var=$(<${HOME}/.66/conf/boot-user/${i}) - for j in ${var[@]}; do - export ${j} - done -done - -66-all up - diff --git a/module/boot-user@/.configure/configure b/module/boot-user@/.configure/configure deleted file mode 100755 index 613877f..0000000 --- a/module/boot-user@/.configure/configure +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -mod="${1}" -home=$(homeof ${mod}) -uid=$(id -u ${mod}) -gid=$(id -g ${mod}) - -if [[ -e ${home}/.xsession ]]; then - mv ${home}/.xsession ${home}/.xsession.bak - chown ${uid}:${gid} ${home}/.xsession.bak -fi -if [[ -e ${home}/.xinitrc ]]; then - mv ${home}/.xinitrc ${home}/.xinitrc.bak - chown ${uid}:${gid} ${home}/.xinitrc.bak -fi - -cp .xsession ${home}/ -chown ${uid}:${gid} ${home}/.xsession - -cp .xinitrc ${home}/ -chown ${uid}:${gid} ${home}/.xinitrc diff --git a/module/boot-user@/.configure/help b/module/boot-user@/.configure/help deleted file mode 100644 index 295d80e..0000000 --- a/module/boot-user@/.configure/help +++ /dev/null @@ -1,78 +0,0 @@ -Modules name: - - boot-user@ -Version: - - 0.2.1 -Description: - - This module configure a set of services for an <user> to properly - deal with Display Manager(a.k.a DM). -Module dependencies: - - none -Optional module dependencies: - - none -Service Dependencies: - - none -Optional service dependencies: - - sddm-66serv - - dbus-66serv - - consolekit-66serv -Package dependencies: - - none -Optional package dependencies: - - consolekit - - sddm - - dbus - ------------------------------------------------------------------------- - -Installation directive: - - # 66-mods.sh boot-user@<user> - # 66-enable boot-user@<user> - - - Dbus and dbus-session@: - - dbus daemon should be enabled and up before - starting the module on a root tree. - - dbus-session@<user> should be enabled on a <user> tree. - It will be brought up at the start of the session. - - Note: .xinitrc file execute an JWM session by default. Edit it - to suit your needs. - ------------------------------------------------------------------------- - -Installed file: - - ${HOME}/.xsession file. - An already existing file is renamed to ${HOME}/.xsession.bak. - - ${HOME}/.xinitrc file. - An already existing file is renamad to ${HOME}/.xinitrc.bak. - -Service: - - All-<user> - - mount-run-<user> - - setenv-<user> - - scandir-<user> - -Runtime: - - It mount /run/user/<uid> of user if doesn't exist. - - It define well-know variable and write it at - ${HOME}/.66/conf/boot-user/boot-user-<user>.conf (see below). - This file is created at every start of the setenv-<user> service. - - It create a scandir as <user> as owner merging the environment from - the directory ${HOME}/.66/conf/boot-user/ and start it. - -Example of ${HOME}/.66/conf/boot-user/boot-user@<user>.conf file: - -HOME=/home/oblive -LOGNAME=obarun -PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin -SHELL=/usr/bin/zsh -DISPLAY=:0 -XDG_RUNTIME_DIR=/run/user/1000 -XDG_CACHE_HOME=/home/oblive/.cache -XDG_CONFIG_HOME=/home/oblive/.config -XDG_DATA_HOME=/home/oblive/.local/share -XDG_DATA_DIRS=/home/oblive/.local/share:/usr/local/share:/usr/share -XDG_SESSION_CLASS=user - -Note: you can set any new variables creating a new file containing one or -multiple key=value pair into the directory ${HOME}/.66/conf/boot-user/ diff --git a/module/boot-user@/All-@M b/module/boot-user@/All-@M deleted file mode 100644 index 9d3a9ac..0000000 --- a/module/boot-user@/All-@M +++ /dev/null @@ -1,5 +0,0 @@ -[main] -@type = bundle -@description = "First service called to start a scandir for @I user" -@user = (root) -@contents = ( mount-run-@I setenv-@I scandir-@I ) diff --git a/module/boot-user@/.configure/.xinitrc b/module/boot-user@/configure/.xinitrc similarity index 69% rename from module/boot-user@/.configure/.xinitrc rename to module/boot-user@/configure/.xinitrc index f6b804e..5dd061f 100755 --- a/module/boot-user@/.configure/.xinitrc +++ b/module/boot-user@/configure/.xinitrc @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!@BINDIR@/bash if [ -d /etc/X11/xinit/xinitrc.d ] ; then for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do @@ -7,15 +7,14 @@ if [ -d /etc/X11/xinit/xinitrc.d ] ; then unset f fi -list=( $(ls -1 ${HOME}/.66/conf/boot-user) ) +list=( $(ls -1 @PATH_ENVIRONMENT@) ) for i in ${list[@]};do - var=$(<${HOME}/.66/conf/boot-user/${i}) + var=$(@PATH_ENVIRONMENT@/${i}) for j in ${var[@]}; do export ${j} done done - 66-all up ## Try consolekit @@ -26,6 +25,4 @@ else fi ## Select the session to start -${cmd} jwm -#${cmd} openbox-session -#${cmd} startkde +${cmd} @DESKTOP_CMDLINE@ diff --git a/module/boot-user@/configure/.xsession b/module/boot-user@/configure/.xsession new file mode 100755 index 0000000..6a46e9e --- /dev/null +++ b/module/boot-user@/configure/.xsession @@ -0,0 +1,12 @@ +#!@BINDIR@/bash + +list=( $(ls -1 @PATH_ENVIRONMENT@) ) +for i in ${list[@]};do + var=$(<@PATH_ENVIRONMENT@/${i}) + for j in ${var[@]}; do + export ${j} + done +done + +66-all up + diff --git a/module/boot-user@/configure/configure b/module/boot-user@/configure/configure new file mode 100755 index 0000000..8335e1b --- /dev/null +++ b/module/boot-user@/configure/configure @@ -0,0 +1,90 @@ +#!@BINDIR@/sh + +## 66-yeller variable +export PROG="${MOD_NAME}" +export VERBOSITY="${MOD_VERBOSITY}" +export CLOCK_ENABLED=0 + +owner="${1}" +home=$(homeof "${owner}") +uid=$(id -u "${owner}") +gid=$(id -g "${owner}") + +home_env="${home}/${MOD_SERVICE_USERCONFDIR}svscan@${owner}" + +die(){ + 66-yeller -fc "${@}" + exit 111 +} + +check_empty_var(){ + name="${1}" var_value="${2}" + if [ -z "${var_value}" ]; then + die invalid value for variable: "${name}" + fi +} + +enable(){ + name="${1}" + 66-yeller %benable%n service: "${name}" + touch "${MOD_MODULE_DIR}/service/${name}" || die "unable to enable ${MOD_MODULE_DIR}/service/${1}" +} + +disable(){ + name="${1}" + 66-yeller %bdisable%n service: "${name}" + rm -f "${MOD_MODULE_DIR}/service/${name}" || die "disable to enable ${MOD_MODULE_DIR}/service/${1}" +} + +if execl-toc -X -V DISPLAY_MANAGER; then + + check_empty_var "DISPLAY_MANAGER" "${DISPLAY_MANAGER}" + + enable "display-manager@${DISPLAY_MANAGER}" + + 66-yeller set environment at .xsession file to: %b"${home_env}"%n + sed -i "s:@PATH_ENVIRONMENT@:${home_env}:g" ".xsession" || die "unable to set environment directory at .xsession file" + + if [ -e "${home}/.xsession" ]; then + 66-yeller -W "move existing ${home}/.xsession file to ${home}/.xsession.bak" + mv "${home}/.xsession" "${home}/.xsession.bak" || exit 111 + fi + + 66-yeller "create ${home}/.xsession" + cp .xsession "${home}/" || exit 111 + chown "${uid}":"${gid}" "${home}/.xsession" || exit 111 +fi + +if execl-toc -X -V CONSOLE_TRACKER; then + + check_empty_var "CONSOLE_TRACKER" "${CONSOLE_TRACKER}" + + enable "console-tracker@${CONSOLE_TRACKER}" +fi + +if [ "${XDG_RUNTIME}" = "yes" ]; then + enable "mount-run@${owner}" +else + disable "mount-run@${owner}" +fi + +if execl-toc -X -V DESKTOP_CMDLINE; then + + check_empty_var "DESKTOP_CMDLINE" "${DESKTOP_CMDLINE}" + + 66-yeller set environment at .xinitrc file to: %b"${home_env}"%n + sed -i "s:@PATH_ENVIRONMENT@:${home_env}:g" ".xinitrc" || die "unable to set environment directory at .xinitrc file" + 66-yeller set commandline at .xinitrc file to: %b"${DESKTOP_CMDLINE}"%n + sed -i "s:@DESKTOP_CMDLINE@:${DESKTOP_CMDLINE}:g" ".xinitrc" || die "unable to set environment directory at .xinitrc file" + + if [ -e "${home}/.xinitrc" ]; then + 66-yeller -W "move existing ${home}/.xinitrc file to ${home}/.xinitrc.bak" + mv "${home}/.xinitrc" "${home}/.xinitrc.bak" || exit 111 + fi + + 66-yeller -c "create ${home}/.xinitrc" + cp .xinitrc "${home}/" || exit 111 + chown "${uid}":"${gid}" "${home}/.xinitrc" || exit 111 +fi + +66-yeller "%bsuccessfully%n configured\n" diff --git a/module/boot-user@/env-@M/setenv-@M b/module/boot-user@/env-@M/setenv-@M deleted file mode 100644 index 54158c0..0000000 --- a/module/boot-user@/env-@M/setenv-@M +++ /dev/null @@ -1,67 +0,0 @@ -[main] -@type = oneshot -@description = "Set well-know variable for @I user" -@user = (root) - -[start] -@build = auto -@runas = @I -@execute = -( - execl-subuidgid - backtick -n HOME { homeof @I } - importas -u HOME HOME - foreground - { - if -nt { test -d ${HOME}/.66/conf/boot-user } - mkdir -p ${HOME}/.66/conf/boot-user - } - redirfd -w 1 ${HOME}/.66/conf/boot-user/boot-user@@I.conf - - ## GENERAL VARIABLES - - if { 66-echo HOME=${HOME} } - if { 66-echo LOGNAME=@I } - if { 66-echo USER=@I } - - foreground { - importas PATH PATH - 66-echo -- PATH=${PATH} - } - foreground { - backtick -D /usr/bin/sh -n shell { - pipeline { getent passwd ${UID} } - cut -d: -f7 - } - importas -u shell shell - 66-echo -- SHELL=${shell} - } - foreground - { - backtick -n x - { - sh -c "d=0 ; while true ; do \ - if [ ! -e "/tmp/.X$d-lock" -o -S "/tmp/.X11-unix/X$d" ]; then \ - 66-echo -- $d ; \ - break ; \ - fi ; \ - d=$(($d + 1)) ; \ - done ;" - } - importas -u x x - 66-echo -- DISPLAY=:${x} - } - ## DBUS - - if { 66-echo -- DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${UID}/dbus } - - ## XDG variables - - if { 66-echo -- XDG_RUNTIME_DIR=/run/user/${UID} } - if { 66-echo -- XDG_CACHE_HOME=${HOME}/.cache } - if { 66-echo -- XDG_CONFIG_HOME=${HOME}/.config } - if { 66-echo -- XDG_DATA_HOME=${HOME}/.local/share } - if { 66-echo -- XDG_DATA_DIRS=${HOME}/.local/share:/usr/local/share:/usr/share } - 66-echo -- XDG_SESSION_CLASS=user - -) diff --git a/module/boot-user@/mount-@M/mount-run-@M b/module/boot-user@/mount-@M/mount-run-@M deleted file mode 100644 index d5d6680..0000000 --- a/module/boot-user@/mount-@M/mount-run-@M +++ /dev/null @@ -1,17 +0,0 @@ -[main] -@type = oneshot -@description = "Mount /run/user directory of @I" -@user = (root) - -[start] -@build = auto -@execute = -( - ## create /run/user/<uid> - execl-subuidgid -o @I - foreground { - if -nt { mountpoint -q /run/user/${UID} } - if { mkdir -p /run/user/${UID} } - mount -o noatime,nodev,nosuid,gid=${GID},uid=${UID},mode=0700,size=64M -t tmpfs user /run/user/${UID} - } -) diff --git a/module/boot-user@/scandir-@M b/module/boot-user@/scandir-@M deleted file mode 100644 index 7c2f26b..0000000 --- a/module/boot-user@/scandir-@M +++ /dev/null @@ -1,18 +0,0 @@ -[main] -@type = longrun -@description = "Start a scandir for @I" -@user = ( root ) -@options = ( log ) -@depends = ( mount-run-@I setenv-@I ) -@notify = 3 -@timeout-up = 3000 - -[start] -@build = auto -@runas = @I -@execute = -( -s6-setsid -qb -- -umask 022 -66-scandir -v3 -d3 -cu -e /home/@I/.66/conf/boot-user -) diff --git a/module/boot-user@/service@/mount-run@ b/module/boot-user@/service@/mount-run@ new file mode 100644 index 0000000..750d790 --- /dev/null +++ b/module/boot-user@/service@/mount-run@ @@ -0,0 +1,19 @@ +[main] +@type = oneshot +@version = @version@ +@description = "Mount /run/user directory of user @I" +@user = ( root ) +@options = ( log ) + +[start] +@build = auto +@execute = +( + if { 66-yeller -p mount-run@@I starts... } + if -nt { + + execl-subuidgid -o @I + execl-toc -X -m /run/user/${UID} -o noatime,nodev,nosuid,gid=${GID},uid=${UID},mode=0700,size=64M -t tmpfs -d user + } + 66-yeller -fp mount-run@@I crashed! +) diff --git a/package/info b/package/info new file mode 100644 index 0000000..d72eb48 --- /dev/null +++ b/package/info @@ -0,0 +1,3 @@ +package=boot-user-66serv +version=0.3.0 +package_macro_dir=66 diff --git a/package/modes b/package/modes new file mode 100644 index 0000000..e67454a --- /dev/null +++ b/package/modes @@ -0,0 +1 @@ +configure 0755 diff --git a/package/targets.mak b/package/targets.mak new file mode 100644 index 0000000..3a177a6 --- /dev/null +++ b/package/targets.mak @@ -0,0 +1,9 @@ +SCRIPT_TARGET := \ +module/boot@/configure/.xinitrc \ +module/boot@/configure/.xsession + +SERVICE_TARGET := service/boot-user@ +MODULE_TARGET := $(shell find module/boot-user@/service -type f) +MODULE_INSTANCE_TARGET := $(shell find module/boot-user@/service@ -type f) + +MODULE_CONFIGURE_TARGET := module/boot-user@/configure/configure diff --git a/scripts/66-mods.sh b/scripts/66-mods.sh deleted file mode 100755 index 4ddf0d6..0000000 --- a/scripts/66-mods.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/bash -# Copyright (c) 2015-2019 Eric Vidal <eric@obarun.org> -# All rights reserved. -# -# This file is part of Obarun. It is subject to the license terms in -# the LICENSE file found in the top-level directory of this -# distribution. -# This file may not be copied, modified, propagated, or distributed -# except according to the terms contained in the LICENSE file. - -PROG="66-mods.sh" -service_system="${service_system:-/usr/lib/66/service}" -module_system="${module_system:-/usr/lib/66/module}" -force=0 - -out() { - msg="${1}" - 66-echo -- $PROG: $msg -} - -die() { - out "${1}" - exit 111 -} - -usage () { -cat <<EOF -$PROG [ -h ] [ -H ] [ -f ] module@instance - -$PROG <options> modules@instance - -options : - -h: print this help - -H: print module help - -f: force to overwrite an existing module -EOF -exit 0 -} - -for arg ; do - case "$arg" in - -h|--help) usage ;; - -H|--help-module) hm=1 ;; - -f|--force) force=1 ;; - -*) die "fatal: unknown option $arg" ;; - *) target+=( $arg ) ;; - esac -done - -if [[ "${target[0]}" != *"@"* ]];then - die "fatal: invalid argument -- not a module name" -fi - -mod="${target[0]}" -mod="${mod%%@*}" -mod="${mod%%@*}@" -insta="${target[0]}" -insta="${insta##*@}" -service="${mod}${insta}" - -if [[ ! -d ${module_system}/${mod} ]]; then - die "fatal: module ${mod} doesn't exist" -fi - -if (( ${hm} )); then - if [[ -e ${module_system}/${mod}/.configure/help ]]; then - h=$(<${module_system}/${mod}/.configure/help) - 66-echo -- "${h}" - else - out "warning: no help found for ${mod}" - fi - exit 0 -fi - -if [[ -z "${insta}" ]];then - die "fatal: instance for ${mod} is not set" -fi - -if [[ -d ${service_system}/${service} ]]; then - if (( !$force )) ; then - die "fatal: ${service_system}/${service} already exist" - else - rm -rf ${service_system}/${service} || die "fatal: unable to remove ${service_system}/${service}" - fi -fi - -cp -rT ${module_system}/${mod} ${service_system}/${service} || die "fatal: unable to cp ${module_system}/${mod} to ${service_system}/${service}" - -## @I in file -for i in $(find ${service_system}/${service} -mindepth 1 -type f);do - sed -i "s:@I:${insta}:g" $i || die "fatal: unable to sed ${i}" -done - -## change directory name -for i in $(find ${service_system}/${service} -mindepth 1 -type d|grep -v "configure");do - mv $i $(66-echo -- ${i}|sed "s:@M:${insta}:g") || die "fatal: unable to move ${i} to $(echo ${i}|sed "s:@M:${insta}:g")" -done - -## change file name -for i in $(find ${service_system}/${service} -mindepth 1 -type f|grep -v "configure");do - mv $i $(66-echo -- ${i}|sed "s:@M:${insta}:g") || die "fatal: unable to move ${i} to $(echo ${i}|sed "s:@M:${insta}:g")" -done - -## run .configure scripts -if [[ -x ${service_system}/${service}/.configure/configure ]]; then - cd ${service_system}/${service}/.configure/ - ${service_system}/${service}/.configure/configure ${insta} || die "fatal: unable to configure ${service_system}/${service}" - rm -rf ${service_system}/${service}/.configure || die "fatal: unable to remove ${service_system}/${service}/.configure" -fi diff --git a/service/boot-user@ b/service/boot-user@ new file mode 100644 index 0000000..5848dff --- /dev/null +++ b/service/boot-user@ @@ -0,0 +1,38 @@ +[main] +@type = module +@version = @VERSION@ +@description = "Configure a nested supervision tree for @I user" +@user = ( root ) +@options = ( env ) +@depends = ( scandir@@I ) + +[regex] +@configure = "@I" +@infiles = ( ::@version@=@VERSION@ ) + +[environment] +## Uncomment it to use a display manager. +## Can be any display manager as long as the +## corresponding frontend file exist on your system +## e.g sddm,lightdm,... +## It also prepare the .xsession file. + +@DISPLAY_MANAGER@ + +## Uncomment it to use a console tracker. +## Can be any console tracker as long as the +## corresponding frontend file exist on your system +## e.g consolekit,elogind,... + +@CONSOLE_TRACKER@ + +## Create and mount the XDG_RUNTIME directory +## at /run/user/@I [yes|no] + +@XDG_RUNTIME@ + +## Command to use in your .xinitrc +## to launch your desktop e.g.: openbox-session. +## If commented the .xinitrc file is not configured. + +@DESKTOP_CMDLINE@ diff --git a/tools/install.sh b/tools/install.sh new file mode 100755 index 0000000..89f9428 --- /dev/null +++ b/tools/install.sh @@ -0,0 +1,64 @@ +#!/bin/sh + +usage() { + echo "usage: $0 [-D] [-l] [-m mode] src dst" 1>&2 + exit 1 +} + +mkdirp=false +symlink=false +mode=0755 + +while getopts Dlm: name ; do + case "$name" in + D) mkdirp=true ;; + l) symlink=true ;; + m) mode=$OPTARG ;; + ?) usage ;; + esac +done +shift $(($OPTIND - 1)) + +test "$#" -eq 2 || usage +src=$1 +dst=$2 +tmp="$dst.tmp.$$" + +case "$dst" in + */) echo "$0: $dst ends in /" 1>&2 ; exit 1 ;; +esac + +set -C +set -e + +if $mkdirp ; then + umask 022 + case "$2" in + */*) mkdir -p "${dst%/*}" ;; + esac +fi + +trap 'rm -f "$tmp"' EXIT INT QUIT TERM HUP + +umask 077 + +if $symlink ; then + ln -s "$src" "$tmp" +else + cat < "$1" > "$tmp" + chmod "$mode" "$tmp" +fi + +mv -f "$tmp" "$dst" +if test -d "$dst" ; then + rm -f "$dst/$(basename $tmp)" + if $symlink ; then + mkdir "$tmp" + ln -s "$src" "$tmp/$(basename $dst)" + mv -f "$tmp/$(basename $dst)" "${dst%/*}" + rmdir "$tmp" + else + echo "$0: $dst is a directory" 1>&2 + exit 1 + fi +fi -- GitLab