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