Skip to content
Snippets Groups Projects
Commit 641c476c authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

first commit

parents
No related branches found
No related tags found
No related merge requests found
*-66mod/
Main author:
Eric Vidal <eric@obarun.org>
LICENSE 0 → 100644
Copyright (c) 2018-2019 Eric Vidal <eric@obarun.org>
All rights reserved.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
NEWS 0 → 100644
Changelog for boot-user-66mod
In 0.0.1
----------
- first commit.
#!/usr/bin/bash
if [ -d /etc/X11/xinit/xinitrc.d ] ; then
for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
[ -x "$f" ] && . "$f"
done
unset f
fi
var=$(<${HOME}/.66/conf/boot-user-${USER}.conf)
for i in ${var[@]}; do
export ${i}
done
66-all up
sleep 03
## Try consolekit
if 66-which -q ck-launch-session; then
cmd="exec ck-launch-session $@"
else
cmd="exec $@"
fi
## Select the session to start
${cmd} jwm
#${cmd} openbox-session
#${cmd} startkde
#!/usr/bin/bash
var=$(<${HOME}/.66/conf/boot-user-${USER}.conf)
for i in ${var[@]}; do
export ${i}
done
66-all up
sleep 03
#!/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
Modules name:
- boot-user-@
Version:
- 0.0.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
Package dependencies:
- none
Optional package dependencies:
- consolekit
- sddm
- dbus
------------------------------------------------------------------------
Installation directive:
# 66-mods boot-user-@<user>
# 66-enable boot-user-<user>
- If you use consolekit do not enable it daemon. It should be launched
by the daemon of the DM directly. Oherwise, conflicts can occur
between the DM daemon and consolekit daemon.
- 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-<user>.conf (see below).
- It create a scandir as <user> as owner merging the environment of
${HOME}/.66/conf/boot-user-<user>.conf and start it.
Example of ${HOME}/.66/conf/boot-user-<user>.conf file:
HOME=/home/obarun
LOGNAME=obarun
PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin
SHELL=/usr/bin/zsh
XDG_RUNTIME_DIR=/run/user/1000
XDG_CACHE_HOME=/home/obarun/.cache
XDG_CONFIG_HOME=/home/obarun/.config
XDG_DATA_HOME=/home/obarun/.local/share
XDG_DATA_DIRS=/home/obarun/.local/share:/usr/local/share:/usr/share
XDG_SESSION_CLASS=user
[main]
@type = bundle
@name = All-@MOD@
@description = "First service called to start a scandir for @MOD@ user"
@user = (root)
@contents = ( mount-run-@MOD@ setenv-@MOD@ scandir-@MOD@ )
[main]
@type = oneshot
@name = setenv-@MOD@
@description = "Set well-know variable for @MOD@ user"
@user = (root)
[start]
@build = auto
@runas = @MOD@
@execute =
(
execl-subuidgid
backtick -n HOME { homeof @MOD@ }
importas -u HOME HOME
redirfd -w 1 ${HOME}/.66/conf/boot-user-@MOD@.conf
## GENERAL VARIABLES
if { 66-echo HOME=${HOME} }
if { 66-echo LOGNAME=@MOD@ }
if { 66-echo USER=@MOD@ }
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
if { 66-echo SHELL=${shell} }
}
## 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
)
[main]
@type = oneshot
@name = mount-run-@MOD@
@description = "Mount /run/user directory of @MOD@"
@user = (root)
[start]
@build = auto
@execute =
(
## create /run/user/<uid>
execl-subuidgid -o @MOD@
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}
}
)
[main]
@type = oneshot
@name = runtime-@MOD@
@description = "Launch all tree enabled of @MOD@"
@user = ( root )
@depends = ( scandir-@MOD@ )
[start]
@build = auto
@execute = (
s6-setuidgid @MOD@
66-all up
)
[stop]
@build = auto
@execute = (
s6-setuidgid @MOD@
66-all down
)
[main]
@type = longrun
@name = scandir-@MOD@
@description = "Start a scandir for @MOD@"
@user = ( root )
@options = ( log )
@depends = ( mount-run-@MOD@ setenv-@MOD@ )
@notify = 3
@timeout-up = 3000
[start]
@build = auto
@runas = @MOD@
@execute =
(
s6-setsid -qb --
umask 022
66-scandir -v3 -d3 -cu -e /home/@MOD@/.66/conf/boot-user-@MOD@.conf
)
#!/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_name="${mod}"
mod="${mod%%@*}@"
insta="${target[0]}"
insta="${insta##*@}"
mod_name="${mod_name}${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}/${mod_name} ]]; then
if (( !$force )) ; then
die "fatal: ${service_system}/${mod_name} already exist"
else
rm -rf ${service_system}/${mod_name} || die "fatal: unable to remove ${service_system}/${mod_name}"
fi
fi
cp -rT ${module_system}/${mod} ${service_system}/${mod_name} || die "fatal: unable to cp ${module_system}/${mod} to ${service_system}/${mod_name}"
## @MOD@ in file
for i in $(find ${service_system}/${mod_name} -mindepth 1 -type f);do
sed -i "s:@MOD@:${insta}:g" $i || die "fatal: unable to sed ${i}"
done
## change directory name
for i in $(find ${service_system}/${mod_name} -mindepth 1 -type d|grep -v "configure");do
mv $i $(66-echo -- ${i}|sed "s:@MOD@:${insta}:g") || die "fatal: unable to move ${i} to $(echo ${i}|sed "s:@MOD@:${insta}:g")"
done
## change file name
for i in $(find ${service_system}/${mod_name} -mindepth 1 -type f|grep -v "configure");do
mv $i $(66-echo -- ${i}|sed "s:@MOD@:${insta}:g") || die "fatal: unable to move ${i} to $(echo ${i}|sed "s:@MOD@:${insta}:g")"
done
## run .configure scripts
if [[ -x ${service_system}/${mod_name}/.configure/configure ]]; then
cd ${service_system}/${mod_name}/.configure/
${service_system}/${mod_name}/.configure/configure ${insta} || die "fatal: unable to configure ${service_system}/${mod_name}"
rm -rf ${service_system}/${mod_name}/.configure || die "fatal: unable to remove ${service_system}/${mod_name}/.configure"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment