From f6dad6269ab3228ead055291b846d2a9edb04564 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 20 Dec 2012 15:33:34 +0100 Subject: mltk basic script :) --- mltk | 58 +++++++ remote/setup-tools.sh | 174 ------------------- remote/setup_tools | 188 +++++++++++++++++++++ remote/tools/base/base.build | 4 +- remote/tools/base/data/README | 3 - remote/tools/base/data/etc/profile | 57 +++++++ .../data/etc/systemd/system/network-fast.service | 8 + remote/tools/base/data/etc/udhcpc.default.script | 64 +++++++ remote/tools/base/data/profile | 57 ------- .../data/etc/systemd/system/plymouth-halt.service | 11 ++ .../data/etc/systemd/system/plymouth-kexec.service | 11 ++ .../etc/systemd/system/plymouth-poweroff.service | 11 ++ .../etc/systemd/system/plymouth-quit-wait.service | 8 + .../data/etc/systemd/system/plymouth-quit.service | 8 + .../etc/systemd/system/plymouth-read-write.service | 9 + .../etc/systemd/system/plymouth-reboot.service | 11 ++ .../data/etc/systemd/system/plymouth-start.service | 13 ++ .../system/systemd-ask-password-plymouth.path | 13 ++ .../system/systemd-ask-password-plymouth.service | 12 ++ remote/tools/plymouth/plymouth.build | 23 +-- remote/tools/plymouth/plymouth.conf | 3 +- remote/tools/systemd/systemd.build | 2 +- remote/tools/udev/udev.build | 6 +- server/build_core | 143 +++++++++------- server/build_core.old | 64 ------- 25 files changed, 571 insertions(+), 390 deletions(-) delete mode 100755 remote/setup-tools.sh create mode 100755 remote/setup_tools delete mode 100644 remote/tools/base/data/README create mode 100644 remote/tools/base/data/etc/profile create mode 100644 remote/tools/base/data/etc/systemd/system/network-fast.service create mode 100755 remote/tools/base/data/etc/udhcpc.default.script delete mode 100644 remote/tools/base/data/profile create mode 100644 remote/tools/plymouth/data/etc/systemd/system/plymouth-halt.service create mode 100644 remote/tools/plymouth/data/etc/systemd/system/plymouth-kexec.service create mode 100644 remote/tools/plymouth/data/etc/systemd/system/plymouth-poweroff.service create mode 100644 remote/tools/plymouth/data/etc/systemd/system/plymouth-quit-wait.service create mode 100644 remote/tools/plymouth/data/etc/systemd/system/plymouth-quit.service create mode 100644 remote/tools/plymouth/data/etc/systemd/system/plymouth-read-write.service create mode 100644 remote/tools/plymouth/data/etc/systemd/system/plymouth-reboot.service create mode 100644 remote/tools/plymouth/data/etc/systemd/system/plymouth-start.service create mode 100644 remote/tools/plymouth/data/etc/systemd/system/systemd-ask-password-plymouth.path create mode 100644 remote/tools/plymouth/data/etc/systemd/system/systemd-ask-password-plymouth.service delete mode 100644 server/build_core.old diff --git a/mltk b/mltk index 10c772b2..3af41ce5 100755 --- a/mltk +++ b/mltk @@ -19,4 +19,62 @@ SELF=$(readlink -f $0) ROOT_DIR=$(dirname ${SELF}) +print_usage() { + echo "Toolkit for creating preboot mini-linux for OpenSLX NG (mltk)" + echo "Usage: $(basename ${SELF}) MODULE [OPTION]" + echo -e " MODULE:" + echo -e " \t core \t minimal initramfs (stage 3.1) to mount the system-container (stage 3.2)." + echo -e " \t sys \t minimal systemd-based rootfs including basic tools." + echo -e " OPTION:" + echo -e " \t build \t builds [MODULE]" + echo -e " \t clean \t clean build files for [MODULE]" + echo -e "" + echo -e " Module specific option:" + echo -e " \t sys \t build [TOOL]" + echo -e " \t \t TOOL can be: \t base, busybox, dbus, udev, systemd, plymouth" +} +if [ "x$1" = "x" ]; then + print_usage + exit 0 +elif [ "x$(whoami)" != "xroot" ]; then + echo "ERROR: You need to have root rights to install packages." + exit 1 +fi + +# read setup-tools and build_core +BUILD_CORE=${ROOT_DIR}/server/build_core +SETUP_TOOLS=${ROOT_DIR}/remote/setup_tools + +if [ "x$1" = "xcore" ]; then + [ -e ${BUILD_CORE} ] && . ${BUILD_CORE} + shift + if [ "x$1" = "xbuild" ]; then + generate_stage31 + elif [ "x$1" = "xclean" ]; then + clean_core + else + print_usage + exit 1 + fi +elif [ "x$1" = "xsys" ]; then + [ -e ${SETUP_TOOLS} ] && . ${SETUP_TOOLS} + shift + if [ "x$1" = "xbuild" ]; then + # shift away first 2 parameters + shift + echo "[sys] Building $@" + generate_stage32 $@ + elif [ "x$1" = "xclean" ]; then + shift + echo "[sys] Cleaning $@" + clean_sys $@ + else + print_usage + exit 1 + fi +else + echo "Module $1 not known." + print_usage + exit 1 +fi diff --git a/remote/setup-tools.sh b/remote/setup-tools.sh deleted file mode 100755 index 639ec14f..00000000 --- a/remote/setup-tools.sh +++ /dev/null @@ -1,174 +0,0 @@ -#!/bin/bash - -ROOT_DIR=$(dirname $(readlink -f $0)) -SELF=$(readlink -f $0) - -print_usage() { - echo "create tools for minilinux" - echo "Usage: $(basename ${SELF}) TOOL" -} - -if [ "x$1" = "x" ]; then - print_usage - exit 0 -elif [ "x$(whoami)" != "xroot" ]; then - echo "ERROR: You need to have root rights to install packages." - exit 1 -fi - -#Create tools directory if not exists -TOOL_DIR=${ROOT_DIR}/tools -INIT_DIR=${ROOT_DIR}/stage3.2 - -setup_git () -{ - if [ ! -z "${GIT}" ]; then - GIT_BIN=$(which git) - [ -z "${GIT_BIN}" ] && echo "Installing git..." && apt-get install git - fi -} - -read_config () -{ - TOOL_CONFIG=${TOOL_DIR}/${TOOL}/${TOOL}.conf - - if [ ! -e ${TOOL_CONFIG} ]; then - echo "ERROR: Config for specified tool not found." - exit 1 - fi - - . ${TOOL_CONFIG} -} - -read_build () -{ - BUILD_SCRIPT=${TOOL_DIR}/${TOOL}/${TOOL}.build - - if [ ! -e ${BUILD_SCRIPT} ]; then - echo "ERROR: Build script for specified tool not found." - exit 1 - fi - - . ${BUILD_SCRIPT} -} - -copyfileswithdependencies () -{ - [ ! -d build ] && echo "No build directory for ${TOOL} found." && return - cd build - - - COPYFILES_LIST="list_wanted_stage3.2" - [ -e ${COPYFILES_LIST} ] && rm ${COPYFILES_LIST} - - for FILENAME in ${REQUIRED_BINARIES} - do - for f in $(find . -name ${FILENAME} -type f -executable) - do - [ $(file $f |grep -c ELF) -eq 1 ] && FILE=$f - done - echo "Found ${FILENAME} at ${FILE}. Searching libraries..." - echo ${FILE} >> ${COPYFILES_LIST} - # fetch dependencies - # quick fix to exclude libc*, else it copies unneeded libs... - for i in $(ldd ${FILE} |awk '{print $1 $2 $3}'|grep -v ld-linux|grep -v libc.so*|grep -v linux-gate) - do - arrIN=(${i//=>/ }) - echo "--------------------------------------------------------" - echo "Searching ${arrIN[0]} under $(pwd)..." - LOCAL_MATCHES=$(find . -name $(echo ${arrIN[0]}|awk -F "." '{print $1}').*) - if [ "x${LOCAL_MATCHES}" != "x" ]; - then - for llib in ${LOCAL_MATCHES}; - do - echo "Copying ${llib}" - echo ${llib} >> ${COPYFILES_LIST} - done - else - echo "Did not found ${arrIN[0]} in $(pwd)" - if [ -e ${arrIN[1]} ]; - then - echo -n "Trying ${arrIN[1]} ..." - echo " found! Copying." - echo ${arrIN[1]} >> ${COPYFILES_LIST} - [ -L ${arrIN[1]} ] && echo $(readlink -f ${arrIN[1]}) >> ${COPYFILES_LIST} - fi - fi - done - echo "Copied ${FILENAME}." - echo "-----------------------------------------------------------------" - done - - for LIB in ${REQUIRED_LIBRARIES} - do - for LOCATION in $(find . -name ${LIB}*) - do - echo ${LOCATION} >> ${COPYFILES_LIST} - done - done - - echo "Copying required directories and files from config file..." - for ENTRY in ${REQUIRED_DIRECTORIES} ${REQUIRED_FILES} - do - echo ".${ENTRY}" >> ${COPYFILES_LIST} - done - - #copy to initramfsdir - tar -cpv $(cat ${COPYFILES_LIST}|sort -u) | tar -xpv -C ${INIT_DIR} &>/dev/null - unset REQUIRED_BINARIES - unset REQUIRED_LIBRARIES - unset REQUIRED_DIRECTORIES - unset REQUIRED_FILES -} - -get_basic_libs () { - - [ ! -d ${INIT_DIR} ] && mkdir ${INIT_DIR} - - # copy libc and ld-linux separatly - echo "Looking for libc and ld-linux used for ${SHELL}..." - BASICLIBS="" - for i in $(ldd ${SHELL}) - do - if [ $(echo $i | grep '^/' | grep -c ld) -eq 1 -o $(echo $i | grep '^/' | grep -c libc.so) -eq 1 ]; - then - echo "Found basic lib at: $i" - BASICLIBS="${BASICLIBS} $i $(readlink -f "$i")" - fi - done - tar -cpv ${BASICLIBS} | tar -xpv -C ${INIT_DIR} &>/dev/null - echo "Basic libs copied." -} - -main () { - - if [ "x$1" = "xall" ]; then - tools=$(ls $ROOT_DIR/tools) - set -- $tools - fi - - get_basic_libs - cd ${TOOL_DIR} - while (( "$#" )); do - TOOL=$1 - if [ -d ${TOOL} ]; - then - cd ${TOOL} - read_config - read_build - setup_git - install_dependencies - fetch_source - build - copyfileswithdependencies - post_copy - cd ${TOOL_DIR} - else - echo "Tool directory not found." - fi - shift - done - -} - -main $@ diff --git a/remote/setup_tools b/remote/setup_tools new file mode 100755 index 00000000..cf96df7b --- /dev/null +++ b/remote/setup_tools @@ -0,0 +1,188 @@ +#!/bin/bash + +MODULE_DIR=${ROOT_DIR}/remote + +#Create tools directory if not exists +TOOL_DIR=${MODULE_DIR}/tools +INIT_DIR=${MODULE_DIR}/stage3.2 + +setup_git () +{ + if [ ! -z "${GIT}" ]; then + GIT_BIN=$(which git) + [ -z "${GIT_BIN}" ] && echo "Installing git..." && apt-get install git + fi +} + +read_config () +{ + TOOL_CONFIG=${TOOL_DIR}/${TOOL}/${TOOL}.conf + + if [ ! -e ${TOOL_CONFIG} ]; then + echo "ERROR: Config for specified tool not found." + exit 1 + fi + + . ${TOOL_CONFIG} +} + +read_build () +{ + BUILD_SCRIPT=${TOOL_DIR}/${TOOL}/${TOOL}.build + + if [ ! -e ${BUILD_SCRIPT} ]; then + echo "ERROR: Build script for specified tool not found." + exit 1 + fi + + . ${BUILD_SCRIPT} +} + +copyfileswithdependencies () +{ + [ ! -d build ] && echo "No build directory for ${TOOL} found." && return + cd build + + + COPYFILES_LIST="list_wanted_stage3.2" + [ -e ${COPYFILES_LIST} ] && rm ${COPYFILES_LIST} + + for FILENAME in ${REQUIRED_BINARIES} + do + for f in $(find . -name ${FILENAME} -type f -executable) + do + [ $(file $f |grep -c ELF) -eq 1 ] && FILE=$f + done + echo "Found ${FILENAME} at ${FILE}. Searching libraries..." + echo ${FILE} >> ${COPYFILES_LIST} + # fetch dependencies + # quick fix to exclude libc*, else it copies unneeded libs... + for i in $(ldd ${FILE} |awk '{print $1 $2 $3}'|grep -v ld-linux|grep -v libc.so*|grep -v linux-gate) + do + arrIN=(${i//=>/ }) + echo "--------------------------------------------------------" + echo "Searching ${arrIN[0]} under $(pwd)..." + LOCAL_MATCHES=$(find . -name $(echo ${arrIN[0]}|awk -F "." '{print $1}').*) + if [ "x${LOCAL_MATCHES}" != "x" ]; + then + for llib in ${LOCAL_MATCHES}; + do + echo "Copying ${llib}" + echo ${llib} >> ${COPYFILES_LIST} + done + else + echo "Did not found ${arrIN[0]} in $(pwd)" + if [ -e ${arrIN[1]} ]; + then + echo -n "Trying ${arrIN[1]} ..." + echo " found! Copying." + echo ${arrIN[1]} >> ${COPYFILES_LIST} + [ -L ${arrIN[1]} ] && echo $(readlink -f ${arrIN[1]}) >> ${COPYFILES_LIST} + fi + fi + done + echo "Copied ${FILENAME}." + echo "-----------------------------------------------------------------" + done + + for LIB in ${REQUIRED_LIBRARIES} + do + for LOCATION in $(find . -name ${LIB}*) + do + echo ${LOCATION} >> ${COPYFILES_LIST} + done + done + + echo "Copying required directories and files from config file..." + for ENTRY in ${REQUIRED_DIRECTORIES} ${REQUIRED_FILES} + do + echo ".${ENTRY}" >> ${COPYFILES_LIST} + done + + #copy to initramfsdir + tar -cpv $(cat ${COPYFILES_LIST}|sort -u) | tar -xpv -C ${INIT_DIR} &>/dev/null + unset REQUIRED_BINARIES + unset REQUIRED_LIBRARIES + unset REQUIRED_DIRECTORIES + unset REQUIRED_FILES +} + +get_basic_libs () { + + [ ! -d ${INIT_DIR} ] && mkdir ${INIT_DIR} + + # copy libc and ld-linux separatly + echo "Looking for libc and ld-linux used for ${SHELL}..." + BASICLIBS="" + for i in $(ldd ${SHELL}) + do + if [ $(echo $i | grep '^/' | grep -c ld) -eq 1 -o $(echo $i | grep '^/' | grep -c libc.so) -eq 1 ]; + then + echo "Found basic lib at: $i" + BASICLIBS="${BASICLIBS} $i $(readlink -f "$i")" + fi + done + tar -cpv ${BASICLIBS} | tar -xpv -C ${INIT_DIR} &>/dev/null + echo "Basic libs copied." +} + +generate_stage32 () { + + # if no arguments assume all. + if [ "x$1" = "x" -o "x$1" = "xall" ]; then + tools=$(ls ${TOOL_DIR}) + set -- $tools + fi + + # first copy libc and ld-linux + get_basic_libs + + # now iterate over given tools and copy them + cd ${TOOL_DIR} + while (( "$#" )); do + TOOL=$1 + if [ -d ${TOOL} ]; + then + cd ${TOOL} + read_config + read_build + setup_git + install_dependencies + fetch_source + build + copyfileswithdependencies + post_copy + cd ${TOOL_DIR} + else + echo "Tool directory not found." + fi + shift + done + +} + +clean_sys() { + if [ "x$1" = "x" -o "x$1" = "xall" ]; then + #clean all + [ -d ${INIT_DIR} ] && rm -rf ${INIT_DIR} + for TOOL in $(ls ${TOOL_DIR}); do + clean_tool $TOOL + done + else + while (( "$#" )); do + clean_tool $1 + shift + done + fi +} +clean_tool() { + TOOLDIR=${TOOL_DIR}/$1 + echo "Cleaning ${TOOLDIR}" + [ -e ${TOOLDIR}/.built ] && rm ${TOOLDIR}/.built + [ -e ${TOOLDIR}/.fetched_source ] && rm ${TOOLDIR}/.fetched_source + [ -d ${TOOLDIR}/build ] && rm -rf ${TOOLDIR}/build + [ -d ${TOOLDIR}/src ] && rm -rf ${TOOLDIR}/src + [ -e ${TOOLDIR}/list_binaries_and_files ] && rm ${TOOLDIR}/list_binaries_and_files +} + +#generate_stage32 $@ diff --git a/remote/tools/base/base.build b/remote/tools/base/base.build index fb7b7294..a56982fa 100644 --- a/remote/tools/base/base.build +++ b/remote/tools/base/base.build @@ -52,8 +52,8 @@ post_copy() { echo "PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/openslx/sbin:/openslx/bin\"" \ > ${INIT_DIR}/etc/environment - # copy static bash profile - cp ${TOOL_DIR}/${TOOL}/data/profile ${INIT_DIR}/etc + # copy static files + cp -r ${TOOL_DIR}/${TOOL}/data/* ${INIT_DIR} # copy pam modules, TODO: better way to find arch-dependant interfix... tar -cpv $(dirname $(locate pam_unix.so|grep ^/lib/)) | tar -xpv -C ${INIT_DIR} &>/dev/null diff --git a/remote/tools/base/data/README b/remote/tools/base/data/README deleted file mode 100644 index 48aab378..00000000 --- a/remote/tools/base/data/README +++ /dev/null @@ -1,3 +0,0 @@ -Static files to customized the basic system - -Here comes things like bash config, pam config, etc diff --git a/remote/tools/base/data/etc/profile b/remote/tools/base/data/etc/profile new file mode 100644 index 00000000..3784e784 --- /dev/null +++ b/remote/tools/base/data/etc/profile @@ -0,0 +1,57 @@ +# ~/.bashrc: executed by bash(1) for non-login interactive shells. + +export PATH=\ +/bin:\ +/sbin:\ +/usr/bin:\ +/usr/sbin:\ +/openslx/bin:\ +/openslx/sbin:\ +/openslx/usr/bin:\ +/openslx/usr/sbin + +# If running interactively, then: +if [ "$PS1" ]; then + + if [ "$BASH" ]; then + export PS1="[\u@\h \W]\\$ " + alias ll='ls --color=auto -laFh' + alias ls='ls --color=auto -F' + export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.png=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:'; + else + if [ "`id -u`" -eq 0 ]; then + export PS1='# ' + else + export PS1='$ ' + fi + fi + + export USER=`id -un` + export LOGNAME=$USER + export HOSTNAME=`hostname` + export HISTSIZE=1000 + export HISTFILESIZE=1000 + export PAGER='/bin/more ' + export EDITOR='/bin/vi' + export INPUTRC=/etc/inputrc + export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile + + ### Some aliases + alias ps2='ps facux ' + alias ps1='ps faxo "%U %t %p %a" ' + alias af='ps af' + alias cls='clear' + alias df='df -h' + alias indent='indent -bad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 -cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 -lp -npcs -npsl -nsc -nsob -nss -ts4 ' + #alias bc='bc -l' + alias minicom='minicom -c on' + alias calc='calc -Cd ' + alias bc='calc -Cd ' +fi; + +# Source configuration files from /etc/profile.d +for i in /etc/profile.d/*.sh ; do + if [ -r "$i" ]; then + . $i + fi +done diff --git a/remote/tools/base/data/etc/systemd/system/network-fast.service b/remote/tools/base/data/etc/systemd/system/network-fast.service new file mode 100644 index 00000000..6656b189 --- /dev/null +++ b/remote/tools/base/data/etc/systemd/system/network-fast.service @@ -0,0 +1,8 @@ +[Unit] +Description=Setup Network Connection +After=udev.service + +[Service] +ExecPre=/openslx/bin/ip link set dev eth0 up +ExecStart=/openslx/sbin/udhcpc -O domain -O nissrv -O nisdomain -t 8 -s /etc/udhcpc.default.script -i eth0 + diff --git a/remote/tools/base/data/etc/udhcpc.default.script b/remote/tools/base/data/etc/udhcpc.default.script new file mode 100755 index 00000000..09442a5e --- /dev/null +++ b/remote/tools/base/data/etc/udhcpc.default.script @@ -0,0 +1,64 @@ +#!/bin/sh +# Busybox udhcpc dispatcher script. Copyright (C) 2009 by Axel Beckert. +# +# Based on the busybox example scripts and the old udhcp source +# package default.* scripts. + +RESOLV_CONF="/etc/resolv.conf" + +case $1 in + bound|renew) + [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" + [ -n "$subnet" ] && NETMASK="netmask $subnet" + + ip addr add $ip/$(ipcalc -s -p $ip $subnet|sed s/.*=//) dev $interface + ip route add default via $router + + # read filename from fbgui.conf where ip config should be saved. + ipconf=$(cat /etc/fbgui.conf | grep ip_config | cut -d '=' -f2) + + echo "ip=$ip" > $ipconf + echo "subnet=$subnet" >> $ipconf + echo "broadcast=$broadcast" >> $ipconf + echo "gateway=$router" >> $ipconf + echo "$ip:132.230.4.3:$router:$subnet" > /tmp/ip_config_fbgui + + # Update resolver configuration file + R="" + [ -n "$domain" ] && R="domain $domain +" + count=1; + for i in $dns; do + echo "$0: Adding DNS $i" + R="${R}nameserver $i +" + count=$((count+1)); + done + + if [ -x /sbin/resolvconf ]; then + echo -n "$R" | resolvconf -a "${interface}.udhcpc" + else + echo -n "$R" > "$RESOLV_CONF" + fi + trigger=$(cat /etc/fbgui.conf | grep file_trigger | cut -d '=' -f2) + + echo "gogo" >> $trigger + ;; + + deconfig) + + ;; + + leasefail) + echo "$0: Lease failed: $message" + ;; + + nak) + echo "$0: Received a NAK: $message" + ;; + + *) + echo "$0: Unknown udhcpc command: $1"; + exit 1; + ;; +esac diff --git a/remote/tools/base/data/profile b/remote/tools/base/data/profile deleted file mode 100644 index 12e75661..00000000 --- a/remote/tools/base/data/profile +++ /dev/null @@ -1,57 +0,0 @@ -# ~/.bashrc: executed by bash(1) for non-login interactive shells. - -export PATH=\ -/bin:\ -/sbin:\ -/usr/bin:\ -/usr/sbin:\ -/openslx/bin:\ -/openslx/sbin:\ -/openslx/usr/bin:\ -/openslx/usr/sbin - -# If running interactively, then: -if [ "$PS1" ]; then - - if [ "$BASH" ]; then - export PS1="[\u@\h \W]\\$ " - alias ll='ls -laFh' - alias ls='ls -F' - export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.png=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:'; - else - if [ "`id -u`" -eq 0 ]; then - export PS1='# ' - else - export PS1='$ ' - fi - fi - - export USER=`id -un` - export LOGNAME=$USER - export HOSTNAME=`hostname` - export HISTSIZE=1000 - export HISTFILESIZE=1000 - export PAGER='/bin/more ' - export EDITOR='/bin/vi' - export INPUTRC=/etc/inputrc - export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile - - ### Some aliases - alias ps2='ps facux ' - alias ps1='ps faxo "%U %t %p %a" ' - alias af='ps af' - alias cls='clear' - alias df='df -h' - alias indent='indent -bad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 -cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 -lp -npcs -npsl -nsc -nsob -nss -ts4 ' - #alias bc='bc -l' - alias minicom='minicom -c on' - alias calc='calc -Cd ' - alias bc='calc -Cd ' -fi; - -# Source configuration files from /etc/profile.d -for i in /etc/profile.d/*.sh ; do - if [ -r "$i" ]; then - . $i - fi -done diff --git a/remote/tools/plymouth/data/etc/systemd/system/plymouth-halt.service b/remote/tools/plymouth/data/etc/systemd/system/plymouth-halt.service new file mode 100644 index 00000000..d01ba9b8 --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/plymouth-halt.service @@ -0,0 +1,11 @@ +[Unit] +Description=Show Plymouth Halt Screen +After=getty@tty1.service prefdm.service plymouth-start.service +Before=halt.service +DefaultDependencies=no +ConditionKernelCommandLine=!plymouth.enable=0 + +[Service] +ExecStart=/sbin/plymouthd --mode=shutdown --attach-to-session +ExecStartPost=-/bin/plymouth show-splash +Type=forking diff --git a/remote/tools/plymouth/data/etc/systemd/system/plymouth-kexec.service b/remote/tools/plymouth/data/etc/systemd/system/plymouth-kexec.service new file mode 100644 index 00000000..1fe6e47f --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/plymouth-kexec.service @@ -0,0 +1,11 @@ +[Unit] +Description=Show Plymouth Reboot with kexec Screen +After=getty@tty1.service prefdm.service plymouth-start.service +Before=kexec.service +DefaultDependencies=no +ConditionKernelCommandLine=!plymouth.enable=0 + +[Service] +ExecStart=/sbin/plymouthd --mode=shutdown --attach-to-session +ExecStartPost=-/bin/plymouth show-splash +Type=forking diff --git a/remote/tools/plymouth/data/etc/systemd/system/plymouth-poweroff.service b/remote/tools/plymouth/data/etc/systemd/system/plymouth-poweroff.service new file mode 100644 index 00000000..49742f6e --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/plymouth-poweroff.service @@ -0,0 +1,11 @@ +[Unit] +Description=Show Plymouth Power Off Screen +After=getty@tty1.service prefdm.service plymouth-start.service +Before=poweroff.service +DefaultDependencies=no +ConditionKernelCommandLine=!plymouth.enable=0 + +[Service] +ExecStart=/sbin/plymouthd --mode=shutdown --attach-to-session +ExecStartPost=-/bin/plymouth show-splash +Type=forking diff --git a/remote/tools/plymouth/data/etc/systemd/system/plymouth-quit-wait.service b/remote/tools/plymouth/data/etc/systemd/system/plymouth-quit-wait.service new file mode 100644 index 00000000..56af45a7 --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/plymouth-quit-wait.service @@ -0,0 +1,8 @@ +[Unit] +Description=Wait for Plymouth Boot Screen to Quit +After=rc-local.service plymouth-start.service systemd-user-sessions.service + +[Service] +ExecStart=-/bin/plymouth --wait +Type=oneshot +TimeoutSec=20 diff --git a/remote/tools/plymouth/data/etc/systemd/system/plymouth-quit.service b/remote/tools/plymouth/data/etc/systemd/system/plymouth-quit.service new file mode 100644 index 00000000..be3c1888 --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/plymouth-quit.service @@ -0,0 +1,8 @@ +[Unit] +Description=Terminate Plymouth Boot Screen +After=rc-local.service plymouth-start.service systemd-user-sessions.service + +[Service] +ExecStart=-/bin/plymouth quit +Type=oneshot +TimeoutSec=20 diff --git a/remote/tools/plymouth/data/etc/systemd/system/plymouth-read-write.service b/remote/tools/plymouth/data/etc/systemd/system/plymouth-read-write.service new file mode 100644 index 00000000..caa3973b --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/plymouth-read-write.service @@ -0,0 +1,9 @@ +[Unit] +Description=Tell Plymouth To Write Out Runtime Data +DefaultDependencies=no +After=local-fs.target +Before=sysinit.target + +[Service] +ExecStart=-/bin/plymouth update-root-fs --read-write +Type=oneshot diff --git a/remote/tools/plymouth/data/etc/systemd/system/plymouth-reboot.service b/remote/tools/plymouth/data/etc/systemd/system/plymouth-reboot.service new file mode 100644 index 00000000..dbedd00d --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/plymouth-reboot.service @@ -0,0 +1,11 @@ +[Unit] +Description=Show Plymouth Reboot Screen +After=getty@tty1.service prefdm.service plymouth-start.service +Before=reboot.service +DefaultDependencies=no +ConditionKernelCommandLine=!plymouth.enable=0 + +[Service] +ExecStart=/sbin/plymouthd --mode=shutdown --attach-to-session +ExecStartPost=-/bin/plymouth show-splash +Type=forking diff --git a/remote/tools/plymouth/data/etc/systemd/system/plymouth-start.service b/remote/tools/plymouth/data/etc/systemd/system/plymouth-start.service new file mode 100644 index 00000000..09243001 --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/plymouth-start.service @@ -0,0 +1,13 @@ +[Unit] +Description=Show Plymouth Boot Screen +DefaultDependencies=no +Wants=systemd-ask-password-plymouth.path +After=systemd-vconsole-setup.service systemd-udev-settle.service +Before=systemd-ask-password-plymouth.service +ConditionKernelCommandLine=!plymouth.enable=0 +ConditionPathExists=!/run/plymouth/pid + +[Service] +ExecStart=/sbin/plymouthd --mode=boot --pid-file=/run/plymouth/pid --attach-to-session +ExecStartPost=-/bin/udevadm settle --timeout=30 --exit-if-exists=/sys/class/drm/card0/dev;-/bin/udevadm settle --timeout=30 --exit-if-exists=/sys/class/graphics/fb0/dev; -/bin/plymouth show-splash +Type=forking diff --git a/remote/tools/plymouth/data/etc/systemd/system/systemd-ask-password-plymouth.path b/remote/tools/plymouth/data/etc/systemd/system/systemd-ask-password-plymouth.path new file mode 100644 index 00000000..c2ee4206 --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/systemd-ask-password-plymouth.path @@ -0,0 +1,13 @@ +[Unit] +Description=Forward Password Requests to Plymouth Directory Watch +Documentation=http://www.freedesktop.org/wiki/Software/systemd/PasswordAgents +DefaultDependencies=no +Conflicts=shutdown.target +After=plymouth-start.service +Before=basic.target shutdown.target +ConditionKernelCommandLine=!plymouth.enable=0 +ConditionPathExists=/run/plymouth/pid + +[Path] +DirectoryNotEmpty=/run/systemd/ask-password +MakeDirectory=yes diff --git a/remote/tools/plymouth/data/etc/systemd/system/systemd-ask-password-plymouth.service b/remote/tools/plymouth/data/etc/systemd/system/systemd-ask-password-plymouth.service new file mode 100644 index 00000000..aa9ffc21 --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/systemd-ask-password-plymouth.service @@ -0,0 +1,12 @@ +[Unit] +Description=Forward Password Requests to Plymouth +Documentation=http://www.freedesktop.org/wiki/Software/systemd/PasswordAgents +DefaultDependencies=no +Conflicts=shutdown.target +After=plymouth-start.service +Before=shutdown.target +ConditionKernelCommandLine=!plymouth.enable=0 +ConditionPathExists=/run/plymouth/pid + +[Service] +ExecStart=/bin/systemd-tty-ask-password-agent --watch --plymouth diff --git a/remote/tools/plymouth/plymouth.build b/remote/tools/plymouth/plymouth.build index 08647498..424bc292 100644 --- a/remote/tools/plymouth/plymouth.build +++ b/remote/tools/plymouth/plymouth.build @@ -32,26 +32,11 @@ build() { touch .built fi - # fix path: everything in lib/systemd to usr/lib/systemd - cd $BUILDDIR - - TARLIST="list_files_to_fix_prefix" - [ -f $TARLIST ] && rm $TARLIST - - # find files and symlinks with wrong prefix - for FILE in $(find . -type f -o -type l|grep ^./lib/systemd) - do - echo $FILE >> $TARLIST - done - # copy found files to usr/* - [ ! -d $BUILDDIR/usr ] && mkdir -p $BUILDDIR/usr - tar -cpv $(cat $TARLIST|sort -u) | tar -xpv -C $BUILDDIR/usr - # delete original location - rm -rf ./lib/systemd - cd - - } post_copy() { - : + # copy static dbus systemd unit files to stage3.2 + SYSTEMDDIR=${INIT_DIR}/etc/systemd/system + [ ! -d ${SYSTEMDDIR} ] && mkdir -p ${SYSTEMDDIR} + cp -r ${TOOL_DIR}/${TOOL}/data/* ${INIT_DIR} } diff --git a/remote/tools/plymouth/plymouth.conf b/remote/tools/plymouth/plymouth.conf index 4ade02d6..6c907826 100644 --- a/remote/tools/plymouth/plymouth.conf +++ b/remote/tools/plymouth/plymouth.conf @@ -7,8 +7,7 @@ DEPS=" libpng-dev libdrm-dev" REQUIRED_BINARIES=" plymouth plymouthd" -REQUIRED_DIRECTORIES=" /usr/lib/systemd/system - /usr/local/bin +REQUIRED_DIRECTORIES=" /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib/plymouth diff --git a/remote/tools/systemd/systemd.build b/remote/tools/systemd/systemd.build index ccdffcc0..981e87b6 100644 --- a/remote/tools/systemd/systemd.build +++ b/remote/tools/systemd/systemd.build @@ -42,7 +42,7 @@ post_copy() { # dont clear systemd log at startup # sed -i.bak "s/ExecStart=-\/sbin\/agetty %I 38400/ExecStart=-\/sbin\/agetty %I 38400 --noclear/g" \ - $INIT_DIR/usr/lib/systemd/system/getty@.service +# $INIT_DIR/usr/lib/systemd/system/getty@.service sed -i.bak "s/TTYVTDisallocate=yes/TTYVTDisallocate=no/g" \ $INIT_DIR/usr/lib/systemd/system/getty@.service } diff --git a/remote/tools/udev/udev.build b/remote/tools/udev/udev.build index f16d747e..70ed0b5a 100644 --- a/remote/tools/udev/udev.build +++ b/remote/tools/udev/udev.build @@ -27,9 +27,9 @@ build() { } post_copy() { - #copy systemd specific files - SYSTEMDDIR=$INIT_DIR/etc/systemd/system - [ ! -d $SYSTEMDDIR ] && mkdir -p $SYSTEMDDIR + #copy systemd specific files + SYSTEMDDIR=$INIT_DIR/etc/systemd/system + [ ! -d $SYSTEMDDIR ] && mkdir -p $SYSTEMDDIR cp -r $TOOL_DIR/$TOOL/data/* $INIT_DIR } diff --git a/server/build_core b/server/build_core index d0441c69..4e615520 100755 --- a/server/build_core +++ b/server/build_core @@ -18,71 +18,84 @@ # in the future the prefix should be set via slxsettings ... -ROOT_DIR=$(dirname $(readlink -f $0)) -SELF=$(readlink -f $0) +MODULE_DIR=${ROOT_DIR}/server -STAGE31_STATIC_DIR=${ROOT_DIR}/../data/stage3.1 -STAGE31_DIR=${ROOT_DIR}/stage3.1 -STAGE32_DIR=${ROOT_DIR}/../remote/stage3.2 +STAGE31_STATIC_DIR=${ROOT_DIR}/data/stage3.1 +STAGE31_DIR=${MODULE_DIR}/stage3.1 +STAGE32_DIR=${ROOT_DIR}/remote/stage3.2 # initial checks -if [ "x$(whoami)" != "xroot" ]; then - echo "ERROR: You need to have root rights to install packages." - exit 1 -fi - -if [ ! -d ${STAGE32_DIR} ]; -then - echo "No stage3.2 directory found. Please run setup-tools.sh first." - exit 1 -fi - -if [ ! -e ${STAGE32_DIR}/openslx/bin/busybox ]; -then - echo "Busybox not found, run 'setup-tools.sh busybox' first." - exit 1 -fi - -# shouldn't squashfs-tools be automatically installed as we need them nevertheless!? -# what if it is already on the machine? faster to check with which than the apt-get check? -if [ -z $(which mksquashfs) ]; -then - echo "mksquashfs not found, please install squashfs-tools first." - exit 1 -fi - -# produce stage3.1 -[ ! -d ${STAGE31_DIR} ] && mkdir -p ${STAGE31_DIR} - -# create basic directory structure -mkdir -p ${STAGE31_DIR}/{bin,dev,proc,run,lib,etc,mnt,sys} - -# copy device files from running system -cp -a /dev/{console,kmsg,mem,null,tty,tty0,tty1,tty9,urandom,zero} \ - ${STAGE31_DIR}/dev - -# copy busybox, its libs and static data to stage3.1 -cp -r ${STAGE32_DIR}/openslx/* ${STAGE31_STATIC_DIR}/* ${STAGE31_DIR} - -# fetch the libraries needed for busybox -BASICLIBS="" -for i in $(ldd ${STAGE31_DIR}/bin/busybox); -do - if [ $(echo $i | grep '^/' | grep -c ld) -eq 1 \ - -o $(echo $i | grep '^/' | grep -c libc.so) -eq 1 ]; - then - echo $i - BASICLIBS="$BASICLIBS $i $(readlink -f "$i")" - fi -done -tar cpv $BASICLIBS | tar xpv -C ${STAGE31_DIR} &>/dev/null - -# finalize the initramfs target -[ ! -d ${STAGE32_DIR} ] && echo "No stage3.2 directory found. Please run setup_tools first." && exit 1 -[ -e ${STAGE31_DIR}/mnt/openslx.sqfs ] && rm ${STAGE31_DIR}/mnt/openslx.sqfs - -mksquashfs ${STAGE32_DIR} ${STAGE31_DIR}/mnt/openslx.sqfs -comp xz -b 1M -no-recovery 2>/dev/null - -cd ${STAGE31_DIR} -find . | cpio --format="newc" --create | gzip -9 > ${ROOT_DIR}/initramfs -cd - &>/dev/null +initial_checks() { + if [ ! -d ${STAGE32_DIR} ]; + then + echo "No stage3.2 directory found. Please run setup_tools first." + exit 1 + fi + + if [ ! -e ${STAGE32_DIR}/openslx/bin/busybox ]; + then + echo "Busybox not found, run 'setup_tools busybox' first." + exit 1 + fi + # shouldn't squashfs-tools be automatically installed as we need them nevertheless!? + # what if it is already on the machine? faster to check with which than the apt-get check? + if [ -z $(which mksquashfs) ]; + then + echo "mksquashfs not found, please install squashfs-tools first." + exit 1 + fi +} + +generate_initramfs() { + + # produce stage3.1 + [ ! -d ${STAGE31_DIR} ] && mkdir -p ${STAGE31_DIR} + + # create basic directory structure + mkdir -p ${STAGE31_DIR}/{bin,dev,proc,run,lib,etc,mnt,sys} + + # copy device files from running system + cp -a /dev/{console,kmsg,mem,null,tty,tty0,tty1,tty9,urandom,zero} \ + ${STAGE31_DIR}/dev + + # copy busybox, its libs and static data to stage3.1 + cp -r ${STAGE32_DIR}/openslx/* ${STAGE31_STATIC_DIR}/* ${STAGE31_DIR} + + # fetch the libraries needed for busybox + BASICLIBS="" + for i in $(ldd ${STAGE31_DIR}/bin/busybox); + do + if [ $(echo $i | grep '^/' | grep -c ld) -eq 1 \ + -o $(echo $i | grep '^/' | grep -c libc.so) -eq 1 ]; + then + echo $i + BASICLIBS="$BASICLIBS $i $(readlink -f "$i")" + fi + done + tar cpv $BASICLIBS | tar xpv -C ${STAGE31_DIR} &>/dev/null + +} + +generate_squashfs() { + + # finalize the initramfs target + [ ! -d ${STAGE32_DIR} ] && echo "No stage3.2 directory found. Please run setup_tools first." && exit 1 + [ -e ${STAGE31_DIR}/mnt/openslx.sqfs ] && rm ${STAGE31_DIR}/mnt/openslx.sqfs + + mksquashfs ${STAGE32_DIR} ${STAGE31_DIR}/mnt/openslx.sqfs -comp xz -b 1M -no-recovery 2>/dev/null + + cd ${STAGE31_DIR} + find . | cpio --format="newc" --create | gzip -9 > ${MODULE_DIR}/initramfs + cd - &>/dev/null +} + +generate_stage31() { + initial_checks + generate_initramfs + generate_squashfs +} + +clean_core() { + [ -d ${STAGE31_DIR} ] && rm -rf ${STAGE31_DIR} + [ -e ${MODULE_DIR}/initramfs ] && rm ${MODULE_DIR}/initramfs +} diff --git a/server/build_core.old b/server/build_core.old deleted file mode 100644 index e761eb2e..00000000 --- a/server/build_core.old +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# Copyright (c) 2012 - OpenSLX GmbH -# -# This program is free software distributed under the GPL version 2. -# See http://openslx.org/COPYING -# -# If you have any feedback please consult http://openslx.org/feedback and -# send your feedback to feedback@openslx.org -# -# General information about OpenSLX can be found at http://openslx.org -# -# Server side script to generate stage3.1,2 initial ramfses for OpenSLX Linux -# stateless clients -############################################################################# - -# first parameter is a hash pointing to the target directory -# /srv/openslx/build - -# in the future the prefix should be set via slxsettings ... -SLXPREFIX=/srv/openslx -IRTARGET=${SLXPREFIX}/build/$1 - -# add openslx distro (in)dependent data to the initramfs target -DISTRONAME=ubuntu -DISTROVER=12.04 - -for content in ${SLXPREFIX}/core/base - ${SLXPREFIX}/core/${DISTRONAME}/base - ${SLXPREFIX}/core/${DISTRONAME}/${DISTROVER} ; do - cp -a $content ${IRTARGET} -done - -# add kernel stuff to the initramfs target -KERNELVER= -mkdir -p ${IRTARGET}/lib/modules -cp -a ${SLXPREFIX}/kernel/${KERNELVER}/modules \ - ${IRTARGET}/lib/modules/${KERNELVER} - -# produce stage3.1 -mkdir -p ${IRTARGET}/stage3.1 - -# create the base directory structure for stage3.1 -mkdir -p ${IRTARGET}/stage3.1/{bin,dev,proc,run,lib,etc,mnt,sys} -cp -a /dev/{console,kmsg,mem,null,tty,tty0,tty1,tty9,urandom,zero} \ - ${IRTARGET}/stage3.1/dev -cp ${IRTARGET}/openslx/bin/busybox ${IRTARGET}/stage3.1/bin - -# link the required busybox applets for stage3.1 -for app in insmod modprobe mount mkdir umount sh switch_root ; do - ln -s /bin/busybox ${IRTARGET}/stage3.1/bin/${app} -done - -# add the static stuff for stage3.1 -cp -a ${SLXPREFIX}/core/stage3.1 ${IRTARGET}/stage3.1 - -# finalize the initramfs target -which mksquashfs 2>&1>/dev/null || { echo "Please install SquashFS utilities" ; exit 1 } - -mksquashfs -ef ${IRTARGET}/stage3.1 ${IRTARGET} \ - ${IRTARGET}/stage3.1/mnt/openslx.sqfs -comp xz -b 1M -no-progress -no-recovery 2>/dev/null - -(cd ${IRTARGET}/stage3.1; find . | cpio --format="newc" --create | gzip -9 > ${IRTARGET}/initramfs) - - -- cgit v1.2.3-55-g7522