Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
a2164ac051 | |||
32cfa84a93 | |||
27263a58e8 | |||
09bcac3bbb | |||
c7db8b46ab | |||
54b6a8d842 | |||
41274292e4 | |||
10c5644890 | |||
022c5887a5 | |||
![]() |
b74274ec84 | ||
9142373219 | |||
![]() |
88147c78b3 | ||
a88c0c6036 | |||
720d72ac7d |
4
Makefile
4
Makefile
@@ -62,10 +62,10 @@ install_udev: install_common
|
||||
install $(EMODE) $(UDEVSCRIPTS) $(DESTDIR)$(SCRIPTSDIR)
|
||||
install $(MODE) $(UDEVHOOKS) $(DESTDIR)$(HOOKSDIR)
|
||||
|
||||
install_tmpfiles: install_common
|
||||
install_tmpfiles: install_hook_common
|
||||
install $(MODE) $(TMPFILESHOOKS) $(DESTDIR)$(HOOKSDIR)
|
||||
|
||||
install_sysusers: install_common
|
||||
install_sysusers: install_hook_common
|
||||
install $(MODE) $(SYSUSERSHOOKS) $(DESTDIR)$(HOOKSDIR)
|
||||
|
||||
install_openrc: install_common
|
||||
|
@@ -11,23 +11,23 @@ bundle_action() {
|
||||
}
|
||||
|
||||
db_err_msg() {
|
||||
echo "${CMD_UPD}: fatal: unable to take lock on ${DATABASE} Permission denied"
|
||||
echo "${CMD_UPD}: fatal: unable to take lock on ${DATABASE}: Permission denied"
|
||||
exit 1
|
||||
}
|
||||
|
||||
bundle_err_msg() {
|
||||
echo "${BUNDLE} is not an existing bundle. Create it with ${CMD}."
|
||||
echo "'${BUNDLE}' is not an existing bundle. Create it with ${CMD}."
|
||||
exit 1
|
||||
}
|
||||
|
||||
bundle_entry_err_msg() {
|
||||
name="$1"
|
||||
echo "$name does not exist in bundle ${BUNDLE}!"
|
||||
echo "'$name' does not exist in bundle '${BUNDLE}'!"
|
||||
exit 1
|
||||
}
|
||||
|
||||
bundle_add_err_msg() {
|
||||
echo "Error when trying to add ${CONTENTS}!"
|
||||
echo "Error when trying to add '${CONTENTS}'!"
|
||||
}
|
||||
|
||||
cmd_help() {
|
||||
@@ -154,6 +154,10 @@ for arg in "$@"; do
|
||||
BUNDLE=$arg
|
||||
continue
|
||||
fi
|
||||
if [ "${CONTENTS}" = "" ]; then
|
||||
CONTENTS=$arg
|
||||
continue
|
||||
fi
|
||||
CONTENTS="${CONTENTS} $arg"
|
||||
done
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
# {{{ functions
|
||||
|
||||
@@ -7,8 +7,8 @@ db_action() {
|
||||
}
|
||||
|
||||
a_newbundle() {
|
||||
for j in $new_bundles; do
|
||||
if [ "$j" = "$1" ]; then
|
||||
for i in $new_bundles; do
|
||||
if [ "$i" = "$1" ]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
@@ -16,8 +16,8 @@ a_newbundle() {
|
||||
}
|
||||
|
||||
service_exists() {
|
||||
for k in $all_services; do
|
||||
if [ "$k" = "$1" ]; then
|
||||
for j in $all_services; do
|
||||
if [ "$j" = "$1" ]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
@@ -26,8 +26,8 @@ service_exists() {
|
||||
|
||||
in_newbundle() {
|
||||
bundle_contents=$(db_action contents "$1")
|
||||
for l in $bundle_contents; do
|
||||
if [ "$l" = "$2" ]; then
|
||||
for k in $bundle_contents; do
|
||||
if [ "$k" = "$2" ]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
@@ -42,26 +42,36 @@ in_newbundle() {
|
||||
RCPATH='/etc/s6/rc'
|
||||
DBPATH="${RCPATH}/compiled"
|
||||
SVPATH='/etc/s6/sv'
|
||||
ADMINSVPATH='/etc/s6/adminsv'
|
||||
FALLBACKSVPATH='/etc/s6/fallbacksv'
|
||||
SVDIRS='/run/s6-rc/servicedirs'
|
||||
TIMESTAMP=$(date +%s)
|
||||
|
||||
if [ -e "${DBPATH}" ]; then
|
||||
old_bundles="$(db_action list bundles)"
|
||||
len=0
|
||||
for bundle in $old_bundles; do
|
||||
contents[$len]=$(db_action contents "$bundle")
|
||||
len=$(( len + 1 ))
|
||||
done
|
||||
# Print contents of older bundles, using the format:
|
||||
# <name1>
|
||||
# <sv1> <sv2> <sv3> ... <svN>
|
||||
# <name2>
|
||||
# <sv1> ... <svN>
|
||||
old_bundle_contents=$(
|
||||
for bundle in $(db_action list bundles); do
|
||||
printf '%s\n' "$bundle" "$(db_action contents "$bundle" | paste -sd" ")"
|
||||
done
|
||||
)
|
||||
fi
|
||||
|
||||
if ! s6-rc-compile "${DBPATH}"-"${TIMESTAMP}" "${SVPATH}"; then
|
||||
echo "Error compiling database."
|
||||
echo "Please double check the ${SVPATH} directories. Exiting."
|
||||
if ! s6-rc-compile "${DBPATH}"-"${TIMESTAMP}" "${SVPATH}" "${ADMINSVPATH}"; then
|
||||
echo "Error compiling database. Trying the system fallback paths!"
|
||||
echo "Please double check the ${ADMINSVPATH} directories."
|
||||
if ! s6-rc-compile "${DBPATH}"-"${TIMESTAMP}" "${SVPATH}" "${FALLBACKSVPATH}"; then
|
||||
echo "The system fallback compilation failed. Something is really wrong with your service directories!"
|
||||
echo "Check your ${SVPATH} and ${FALLBACKSVPATH} directories."
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -e "/run/s6-rc" ]; then
|
||||
for dir in ${SVDIRS}/*; do
|
||||
for dir in "${SVDIRS}"/*; do
|
||||
if [ -e "${dir}/down" ]; then
|
||||
s6-svc -x "${dir}"
|
||||
fi
|
||||
@@ -70,8 +80,7 @@ if [ -e "/run/s6-rc" ]; then
|
||||
fi
|
||||
|
||||
if [ -d "${DBPATH}" ]; then
|
||||
ln -sf "${DBPATH}"-"${TIMESTAMP}" "${DBPATH}"/compiled
|
||||
mv -f "${DBPATH}"/compiled "${RCPATH}"
|
||||
ln -sf "${DBPATH}"-"${TIMESTAMP}" "${DBPATH}"/compiled && mv -f "${DBPATH}"/compiled "${RCPATH}"
|
||||
else
|
||||
ln -sf "${DBPATH}"-"${TIMESTAMP}" "${DBPATH}"
|
||||
fi
|
||||
@@ -79,44 +88,33 @@ fi
|
||||
new_bundles=$(db_action list bundles)
|
||||
all_services=$(db_action list all)
|
||||
|
||||
while read -r l && read -r old_contents; do
|
||||
CMD='s6-rc-bundle'
|
||||
|
||||
if [ -n "$old_bundles" ]; then
|
||||
len=0
|
||||
for m in $old_bundles; do
|
||||
old_contents=${contents[$len]}
|
||||
a_newbundle "$m"
|
||||
ret=$?
|
||||
a_newbundle "$l"
|
||||
ret=$?
|
||||
|
||||
for n in $old_contents; do
|
||||
service_exists "$n"
|
||||
ret2=$?
|
||||
|
||||
if [ $ret -eq 1 ]; then
|
||||
if [ $ret2 -eq 0 ]; then
|
||||
new_contents="$new_contents $n"
|
||||
fi
|
||||
else
|
||||
if [ $ret2 -eq 0 ]; then
|
||||
in_newbundle "$m" "$n"
|
||||
ret3=$?
|
||||
|
||||
if [ $ret3 -eq 1 ]; then
|
||||
s6-rc-bundle-update -c "${DBPATH}" add "$m" "$n"
|
||||
fi
|
||||
|
||||
fi
|
||||
for m in $old_contents; do
|
||||
# We should handle the service if it exists and either:
|
||||
# [ $ret -eq 1 ] -> the bundle it is in not doesn't exist yet
|
||||
# ! in_newbundle -> it's not in the bundle it used to be in
|
||||
if service_exists "$m"; then
|
||||
if [ $ret -eq 1 ] || ! in_newbundle "$l" "$m"; then
|
||||
new_contents="$new_contents $m"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
if [ -n "$new_contents" ]; then
|
||||
s6-rc-bundle -c "${DBPATH}" add "$m" $new_contents
|
||||
fi
|
||||
|
||||
new_contents=""
|
||||
len=$(( len + 1 ))
|
||||
done
|
||||
fi
|
||||
|
||||
# If bundle exists, we're only going to update it
|
||||
[ $ret -eq 1 ] || CMD="$CMD-update"
|
||||
|
||||
# Add or update bundle
|
||||
[ -z "$new_contents" ] || "$CMD" -c "${DBPATH}" add "$l" $new_contents
|
||||
|
||||
new_contents=''
|
||||
done <<EOF
|
||||
$old_bundle_contents
|
||||
EOF
|
||||
|
||||
echo "==> Switched to a new database."
|
||||
echo " Remove any old unwanted/unneeded database directories in ${RCPATH}."
|
||||
|
@@ -35,9 +35,10 @@ shutdown_service() {
|
||||
if [ -d "$dir" ] && [ "$dir" != "etc/s6/sv/" ]; then
|
||||
sv=$(basename "$dir")
|
||||
active=$(s6-rc -a list | grep -Fx "$sv" || true)
|
||||
if [ -n $active ]; then
|
||||
s6-rc -d change "$sv"
|
||||
if [ ! "$active" ]; then
|
||||
continue
|
||||
fi
|
||||
s6-rc -d change "$sv"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
@@ -10,7 +10,6 @@ udevd_live() {
|
||||
op="$1"; shift
|
||||
|
||||
case "$op" in
|
||||
#hwdb) /usr/bin/udev-hwdb --usr update ;;
|
||||
hwdb) /usr/bin/udevadm hwdb --update ;;
|
||||
udev-reload) udevd_live; /usr/bin/udevadm control --reload ;;
|
||||
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
|
||||
|
Reference in New Issue
Block a user