Commit 86b23192 authored by EclipseSpark's avatar EclipseSpark

import parrot sources

parents
This diff is collapsed.
# Makefile
## live-config(7) - System Configuration Components
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.
SHELL := sh -e
LANGUAGES = $(shell cd manpages/po && ls)
SCRIPTS = backend/*/*.init frontend/* components/*
all: build
test:
@echo -n "Checking for syntax errors"
@for SCRIPT in $(SCRIPTS); \
do \
sh -n $${SCRIPT}; \
echo -n "."; \
done
@echo " done."
@if [ -x "$$(which checkbashisms 2>/dev/null)" ]; \
then \
echo -n "Checking for bashisms"; \
for SCRIPT in $(SCRIPTS); \
do \
checkbashisms -f -x $${SCRIPT}; \
echo -n "."; \
done; \
echo " done."; \
else \
echo "W: checkbashisms - command not found"; \
echo "I: checkbashisms can be obtained from: "; \
echo "I: http://git.debian.org/?p=devscripts/devscripts.git"; \
echo "I: On Debian based systems, checkbashisms can be installed with:"; \
echo "I: apt-get install devscripts"; \
fi
build:
@echo "Nothing to build."
install:
# Installing backend
mkdir -p $(DESTDIR)/etc/init.d
cp backend/sysvinit/live-config.init $(DESTDIR)/etc/init.d/live-config
mkdir -p $(DESTDIR)/lib/systemd/system
cp backend/systemd/live-config.systemd $(DESTDIR)/lib/systemd/system/live-config.service
# Installing frontend
mkdir -p $(DESTDIR)/bin
cp frontend/* $(DESTDIR)/bin
# Installing components
mkdir -p $(DESTDIR)/lib/live/config
cp components/* $(DESTDIR)/lib/live/config
mkdir -p $(DESTDIR)/var/lib/live/config
# Installing shared data
mkdir -p $(DESTDIR)/usr/share/live/config
cp -r VERSION share/* $(DESTDIR)/usr/share/live/config
# Installing docs
mkdir -p $(DESTDIR)/usr/share/doc/live-config
cp -r COPYING examples $(DESTDIR)/usr/share/doc/live-config
# Installing manpages
for MANPAGE in manpages/en/*; \
do \
SECTION="$$(basename $${MANPAGE} | awk -F. '{ print $$2 }')"; \
install -D -m 0644 $${MANPAGE} $(DESTDIR)/usr/share/man/man$${SECTION}/$$(basename $${MANPAGE}); \
done
for LANGUAGE in $(LANGUAGES); \
do \
for MANPAGE in manpages/$${LANGUAGE}/*; \
do \
SECTION="$$(basename $${MANPAGE} | awk -F. '{ print $$3 }')"; \
install -D -m 0644 $${MANPAGE} $(DESTDIR)/usr/share/man/$${LANGUAGE}/man$${SECTION}/$$(basename $${MANPAGE} .$${LANGUAGE}.$${SECTION}).$${SECTION}; \
done; \
done
uninstall:
# Uninstalling backend
rm -f $(DESTDIR)/etc/init.d/live
rm -f $(DESTDIR)/etc/init.d/live-config
rmdir --ignore-fail-on-non-empty $(DESTDIR)/etc/init.d > /dev/null 2>&1 || true
rmdir --ignore-fail-on-non-empty $(DESTDIR)/etc > /dev/null 2>&1 || true
rm -f $(DESTDIR)/etc/init/live-config.conf
rmdir --ignore-fail-on-non-empty $(DESTDIR)/etc/init > /dev/null 2>&1 || true
rmdir --ignore-fail-on-non-empty $(DESTDIR)/etc > /dev/null 2>&1 || true
rm -f $(DESTDIR)/lib/systemd/system/live-config.service
rmdir --ignore-fail-on-non-empty $(DESTDIR)/lib/systemd/system > /dev/null 2>&1 || true
rmdir --ignore-fail-on-non-empty $(DESTDIR)/lib/systemd > /dev/null 2>&1 || true
# Uninstalling components
rm -rf $(DESTDIR)/lib/live/config
rmdir --ignore-fail-on-non-empty $(DESTDIR)/lib/live > /dev/null 2>&1 || true
rmdir --ignore-fail-on-non-empty $(DESTDIR)/lib > /dev/null 2>&1 || true
rmdir --ignore-fail-on-non-empty $(DESTDIR)/var/lib/live/config > /dev/null 2>&1 || true
rmdir --ignore-fail-on-non-empty $(DESTDIR)/var/lib/live > /dev/null 2>&1 || true
rmdir --ignore-fail-on-non-empty $(DESTDIR)/var/lib > /dev/null 2>&1 || true
rmdir --ignore-fail-on-non-empty $(DESTDIR)/var > /dev/null 2>&1 || true
# Uninstalling shared data
rm -rf $(DESTDIR)/usr/share/live/config
rmdir --ignore-fail-on-non-empty $(DESTDIR)/usr/share/live
# Uninstalling docs
rm -rf $(DESTDIR)/usr/share/doc/live-config
rmdir --ignore-fail-on-non-empty $(DESTDIR)/usr/share/doc > /dev/null 2>&1 || true
rmdir --ignore-fail-on-non-empty $(DESTDIR)/usr/share > /dev/null 2>&1 || true
rmdir --ignore-fail-on-non-empty $(DESTDIR)/usr > /dev/null 2>&1 || true
# Uninstalling manpages
for MANPAGE in manpages/en/*; \
do \
SECTION="$$(basename $${MANPAGE} | awk -F. '{ print $$2 }')"; \
rm -f $(DESTDIR)/usr/share/man/man$${SECTION}/$$(basename $${MANPAGE} .en.$${SECTION}).$${SECTION}; \
done
for LANGUAGE in $(LANGUAGES); \
do \
for MANPAGE in manpages/$${LANGUAGE}/*; \
do \
SECTION="$$(basename $${MANPAGE} | awk -F. '{ print $$3 }')"; \
rm -f $(DESTDIR)/usr/share/man/$${LANGUAGE}/man$${SECTION}/$$(basename $${MANPAGE} .$${LANGUAGE}.$${SECTION}).$${SECTION}; \
done; \
done
for SECTION in $(ls manpages/en/* | awk -F. '{ print $2 }'); \
do \
rmdir --ignore-fail-on-non-empty $(DESTDIR)/usr/share/man/man$${SECTION} > /dev/null 2>&1 || true; \
rmdir --ignore-fail-on-non-empty $(DESTDIR)/usr/share/man/*/man$${SECTION} > /dev/null 2>&1 || true; \
done
rmdir --ignore-fail-on-non-empty $(DESTDIR)/usr/share/man > /dev/null 2>&1 || true
rmdir --ignore-fail-on-non-empty $(DESTDIR)/usr/share > /dev/null 2>&1 || true
rmdir --ignore-fail-on-non-empty $(DESTDIR)/usr > /dev/null 2>&1 || true
rmdir --ignore-fail-on-non-empty $(DESTDIR) > /dev/null 2>&1 || true
clean:
@echo "Nothing to clean."
distclean: clean
@echo "Nothing to distclean."
reinstall: uninstall install
## live-config - System Configuration Components
##
## live-config contains the components that configure a live system during
## the boot process (late userspace).
##
## This is the systemd service for live-config.
[Unit]
Description=live-config contains the components that configure a live system during the boot process (late userspace).
Documentation=man:live-config
Before=basic.target udev.service
DefaultDependencies=no
ConditionPathExists=/bin/live-config
ConditionKernelCommandLine=boot=live
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/live-config
#!/bin/sh
## live-config contains the components that configure a live system during
## the boot process (late userspace).
##
## This is the sysvinit initscript for live-config.
### BEGIN INIT INFO
# Provides: live-config
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: live-config - System Configuration Components
# Description: live-config contains the components that configure a
# live system during the boot process (late userspace).
# X-Start-Before: mountkernfs
# X-Stop-After:
# X-Interactive: true
### END INIT INFO
case "${1}" in
start)
if [ -e /bin/live-config ]
then
/bin/live-config ${@}
fi
;;
force-reload|restart|stop)
;;
esac
#!/bin/sh
## live-config(7) - System Configuration Components
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.
#set -e
Cmdline ()
{
# Reading kernel command line
for _PARAMETER in ${LIVE_CONFIG_CMDLINE}
do
case "${_PARAMETER}" in
live-config.debconf-preseed=*|debconf-preseed=*)
LIVE_DEBCONF_PRESEED="${_PARAMETER#*debconf-preseed=}"
;;
esac
done
}
Init ()
{
# Checking if package is installed or already configured
if [ ! -e /var/lib/dpkg/info/debconf.list ] || \
[ -e /var/lib/live/config/debconf ]
then
exit 0
fi
echo -n " debconf"
}
Config ()
{
if [ -z "${LIVE_DEBCONF_PRESEED}" ]
then
exit 0
fi
for _PRESEED in $(echo ${LIVE_DEBCONF_PRESEED} | sed -e 's/|/ /g')
do
case "${_PRESEED}" in
filesystem)
if ls /lib/live/config-preseed/* 2>&1
then
_PRESEEDS="${_PRESEEDS} $(for _FILE in /lib/live/config-preseed/*; do echo file://${_FILE}; done)"
fi
;;
medium)
if ls /lib/live/mount/medium/live/config-preseed/* 2>&1
then
_PRESEEDS="${_PRESEEDS} $(for _FILE in /lib/live/mount/medium/live/config-preseed/*; do echo file://${_FILE}; done)"
fi
;;
*)
_PRESEEDS="${_PRESEEDS} ${_PRESEED}"
;;
esac
done
for _PRESEED in ${_PRESEEDS}
do
_TMPFILE="$(mktemp -t live-config.XXXXXXXX)"
if echo "${_PRESEED}" | grep -qs file://
then
# local file
cp $(echo ${_PRESEED} | sed 's|file://||') "${_TMPFILE}"
else
# remote file
Setup_network
wget --quiet "${_PRESEED}" -O "${_TMPFILE}"
fi
debconf-set-selections < "${_TMPFILE}"
rm -f "${_TMPFILE}"
done
# Creating state file
touch /var/lib/live/config/debconf
}
Cmdline
Init
Config
#!/bin/sh
## live-config(7) - System Configuration Components
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.
#set -e
Cmdline ()
{
# Reading kernel command line
for _PARAMETER in ${LIVE_CONFIG_CMDLINE}
do
case "${_PARAMETER}" in
live-config.hostname=*|hostname=*)
LIVE_HOSTNAME="${_PARAMETER#*hostname=}"
;;
esac
done
}
Init ()
{
# Checking if package is installed or already configured
if [ -z "${LIVE_HOSTNAME}" ] || \
[ -e /var/lib/live/config/hostname ]
then
exit 0
fi
echo -n " hostname"
}
Config ()
{
# Change hostname only if it is not set
if [ ! -e /etc/hostname ] || \
grep -qs localhost\.localdomain /etc/hostname
then
# Supporting variables within hostnames
if [ -e /bin/ip ]
then
LINK="$(ip -oneline -family link address show dev eth0 | awk '{ print $13 }' | sed -e "s|:|${_IP_SEPARATOR}|g")"
INET="$(ip -oneline -family inet address show dev eth0 | awk '{ print $4 }' | sed -e "s|\.|${_IP_SEPARATOR}|g" -e 's|/.*||')"
INET6="$(ip -oneline -family inet6 address show dev eth0 | awk '{ print $4 }' | sed -e "s|:|${_IP_SEPARATOR}|g" -e 's|/.*||' -e 's|--|-|')"
eval LIVE_HOSTNAME="${LIVE_HOSTNAME}"
fi
echo "${LIVE_HOSTNAME}" > /etc/hostname
else
LIVE_HOSTNAME="$(cat /etc/hostname)"
fi
# Updating hostname in /etc/hosts
if [ -s /etc/hosts ]
then
# /etc/hosts exists but has no 127.0.0.1
if ! grep -Eq "^ *127.0.0.1" /etc/hosts
then
mv /etc/hosts /etc/hosts.tmp
echo "127.0.0.1 localhost ${LIVE_HOSTNAME}" > /etc/hosts
cat /etc/hosts.tmp >> /etc/hosts
rm -f /etc/hosts.tmp
# /etc/hosts exists and has no matching 127.0.0.1
elif ! grep -Eq "^ *127.0.0.1.*${LIVE_HOSTNAME}" /etc/hosts
then
_HOSTS="$(grep -E "^ *127.0.0.1" /etc/hosts | awk '{ $1=""; print $0 }' | sed -e 's|localhost||')"
_HOSTS="$(echo localhost ${_HOSTS} ${LIVE_HOSTNAME} | sed -e 's|^ ||' -e 's| | |g')"
sed -i -e "s|^ *127.0.0.1.*|127.0.0.1 ${_HOSTS}|" /etc/hosts
fi
else
# /etc/hosts does not exist
cat > /etc/hosts << EOF
127.0.0.1 localhost ${LIVE_HOSTNAME}
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF
fi
hostname "${LIVE_HOSTNAME}" || true
# Creating state file
touch /var/lib/live/config/hostname
}
Cmdline
Init
Config
#!/bin/sh
## live-config(7) - System Configuration Components
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.
#set -e
Cmdline ()
{
# Reading kernel command line
for _PARAMETER in ${LIVE_CONFIG_CMDLINE}
do
case "${_PARAMETER}" in
live-config.user-default-groups=*|user-default-groups=*)
LIVE_USER_DEFAULT_GROUPS="${_PARAMETER#*user-default-groups=}"
;;
live-config.user-fullname=*|user-fullname=*)
LIVE_USER_FULLNAME="${_PARAMETER#*user-fullname=}"
;;
live-config.username=*|username=*)
LIVE_USERNAME="${_PARAMETER#*username=}"
;;
esac
done
}
Init ()
{
# Checking if package is installed or already configured
if [ ! -e /var/lib/dpkg/info/live-debconfig.list ] || \
[ -e /var/lib/live/config/live-debconfig_passwd ]
then
exit 0
fi
echo -n " live-debconfig (passwd)"
}
Config ()
{
# Checking if package is already configured differently
if grep -q "^${LIVE_USERNAME}:" /etc/passwd
then
exit 0
fi
# Adjust formating of groups
if [ -n "${LIVE_USER_DEFAULT_GROUPS}" ]
then
LIVE_USER_DEFAULT_GROUPS="$(echo ${LIVE_USER_DEFAULT_GROUPS} | sed -e 's|,| |g')"
fi
# Make sure user is not in sudo group if sudo is disabled
case "${LIVE_CONFIG_NOROOT}" in
true)
LIVE_USER_DEFAULT_GROUPS="$(echo ${LIVE_USER_DEFAULT_GROUPS} | sed -e 's|sudo||')"
;;
esac
# Default password is: live
# passwords can be generated with 'echo "live" | mkpasswd -s',
# a blank password is 'U6aMy0wojraho'.
_PASSWORD="8Ab05sVQ4LLps"
cat > /tmp/live-config.cfg << EOF
live-debconfig live-debconfig/passwd/shadow boolean on
#live-debconfig live-debconfig/passwd/root-password password
#live-debconfig live-debconfig/passwd/root-password-again password
live-debconfig live-debconfig/passwd/root-password-crypted string *
live-debconfig live-debconfig/passwd/user-name string ${LIVE_USERNAME}
live-debconfig live-debconfig/passwd/user-fullname string ${LIVE_USER_FULLNAME}
#live-debconfig live-debconfig/passwd/user-password password
#live-debconfig live-debconfig/passwd/user-password-again password
live-debconfig live-debconfig/passwd/user-password-crypted string ${_PASSWORD}
live-debconfig live-debconfig/passwd/user-home string /home/user
live-debconfig live-debconfig/passwd/user-uid string 1000
live-debconfig live-debconfig/passwd/user-gid string 1000
live-debconfig live-debconfig/passwd/user-default-groups string ${LIVE_USER_DEFAULT_GROUPS}
live-debconfig live-debconfig/passwd/user-system-user boolean false
EOF
live-debconfig-set-selections /tmp/live-config.cfg
rm -f /tmp/live-config.cfg
live-debconfig --debconfig=passwd
# Creating state file
touch /var/lib/live/config/live-debconfig_passwd
}
Cmdline
Init
Config
#!/bin/sh
## live-config(7) - System Configuration Components
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.
#set -e
Cmdline ()
{
# Reading kernel command line
for _PARAMETER in ${LIVE_CONFIG_CMDLINE}
do
case "${_PARAMETER}" in
live-config.user-default-groups=*|user-default-groups=*)
LIVE_USER_DEFAULT_GROUPS="${_PARAMETER#*user-default-groups=}"
;;
live-config.user-fullname=*|user-fullname=*)
LIVE_USER_FULLNAME="${_PARAMETER#*user-fullname=}"
;;
live-config.username=*|username=*)
LIVE_USERNAME="${_PARAMETER#*username=}"
;;
esac
done
}
Init ()
{
# Checking if package is installed or already configured
if [ ! -e /var/lib/dpkg/info/user-setup.list ] || \
[ -e /var/lib/live/config/user-setup ]
then
exit 0
fi
echo -n " user-setup"
}
Config ()
{
# Checking if package is already configured differently
if grep -q "^${LIVE_USERNAME}:" /etc/passwd
then
exit 0
fi
# Adjust formating of groups
if [ -n "${LIVE_USER_DEFAULT_GROUPS}" ]
then
LIVE_USER_DEFAULT_GROUPS="$(echo ${LIVE_USER_DEFAULT_GROUPS} | sed -e 's|,| |g')"
fi
# Make sure user is not in sudo group if sudo is disabled
case "${LIVE_CONFIG_NOROOT}" in
true)
LIVE_USER_DEFAULT_GROUPS="$(echo ${LIVE_USER_DEFAULT_GROUPS} | sed -e 's|sudo||')"
;;
esac
# Default password is: toor
# passwords can be generated with 'echo "live" | mkpasswd -s',
# a blank password is 'U6aMy0wojraho'.
_PASSWORD="X014elvznJq7E"
cat > /tmp/live-config.cfg << EOF
user-setup passwd/make-user boolean true
user-setup passwd/root-password-crypted string *
user-setup passwd/user-password-crypted string ${_PASSWORD}
user-setup passwd/user-default-groups string ${LIVE_USER_DEFAULT_GROUPS}
user-setup passwd/user-fullname string ${LIVE_USER_FULLNAME}
user-setup passwd/username string ${LIVE_USERNAME}
user-setup passwd/user-uid string 1000
EOF
debconf-set-selections < /tmp/live-config.cfg
rm -f /tmp/live-config.cfg
# Workaround for bug in shadow
set +e
/usr/lib/user-setup/user-setup-apply 2>&1 \
| grep -v "Shadow passwords are now on"
set -e
# Creating state file
touch /var/lib/live/config/user-setup
}
Cmdline
Init
Config
#!/bin/sh
## live-config(7) - System Configuration Components
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.
#set -e
Cmdline ()
{
# Reading kernel command line
for _PARAMETER in ${LIVE_CONFIG_CMDLINE}
do
case "${_PARAMETER}" in
live-config.noroot|noroot)
LIVE_CONFIG_NOROOT="true"
;;
live-config.username=*|username=*)
LIVE_USERNAME="${_PARAMETER#*username=}"
;;
esac
done
}
Init ()
{
# Disable root access, no matter what mechanism
case "${LIVE_CONFIG_NOROOT}" in
true)
exit 0
;;
esac
# Checking if package is installed or already configured
if [ ! -e /var/lib/dpkg/info/sudo.list ] || \
[ -e /var/lib/live/config/sudo ]
then
exit 0
fi
echo -n " sudo"
}
Config ()
{
# Skip sudo configuration if username is root
case "${LIVE_USERNAME}" in
root)
exit 0
;;
esac
# Checking if package is already configured differently