Skip to content

Commit

Permalink
minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
DemiMarie committed Dec 23, 2022
1 parent 239bde8 commit 0e22478
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
25 changes: 13 additions & 12 deletions debian/qubes-core-agent.postinst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash --
# postinst script for core-agent-linux
#
# see: dh_installdeb(1)
Expand All @@ -20,18 +20,18 @@ set -e
# the debian-policy package


debug() {
debug () {
if [ "${DEBDEBUG}" == "1" ]; then
echo -e "$@"
fi
}

# FIXME: add user units support to is_static()/is_masked()/mask()/unmask() functions
is_static() {
is_static () {
[ -f "/lib/systemd/system/$1" ] && ! grep -q '^[[].nstall]' "/lib/systemd/system/$1"
}

is_masked() {
is_masked () {
if [ ! -L /etc/systemd/system/"$1" ]
then
return 1
Expand All @@ -44,19 +44,19 @@ is_masked() {
return 1
}

mask() {
mask () {
ln -sf /dev/null /etc/systemd/system/"$1"
}

unmask() {
unmask () {
if ! is_masked "$1"
then
return 0
fi
rm -f /etc/systemd/system/"$1"
}

preset_units() {
preset_units () {
local represet=
# shellcheck disable=SC2206
local extra_opts=( $3 )
Expand Down Expand Up @@ -97,7 +97,7 @@ preset_units() {
systemctl daemon-reload
}

installSerialConf() {
installSerialConf () {
debug "Installing over-ridden serial.conf init script..."
if [ -e /etc/init/serial.conf ]; then
cp /usr/share/qubes/serial.conf /etc/init/serial.conf
Expand All @@ -117,21 +117,22 @@ case "${1}" in

# ensure that hostname resolves to 127.0.1.1 resp. ::1 and that /etc/hosts is
# in the form expected by qubes-sysinit.sh
hostname=$(hostname)
if ! is_protected_file /etc/hostname ; then
for ip in '127\.0\.1\.1' '::1'; do
if grep -q "^${ip}\(\s\|$\)" /etc/hosts; then
sed -i "/^${ip}\s/,+0s/\(\s$(hostname)\)\+\(\s\|$\)/\2/g" /etc/hosts || true
sed -i "s/^${ip}\(\s\|$\).*$/\0 $(hostname)/" /etc/hosts || true
sed -i "/^${ip}\s/,+0s/\(\s$hostname\)\+\(\s\|$\)/\2/g" /etc/hosts || true
sed -i "s/^${ip}\(\s\|$\).*$/\0 $hostname/" /etc/hosts || true
else
echo "${ip//\\/} $(hostname)" >> /etc/hosts || true
echo "${ip//\\/} $hostname" >> /etc/hosts || true
fi
done
fi

# remove hostname from 127.0.0.1 line (in debian the hostname is by default
# resolved to 127.0.1.1)
if ! is_protected_file /etc/hosts ; then
sed -i "/^127\.0\.0\.1\s/,+0s/\(\s$(hostname)\)\+\(\s\|$\)/\2/g" /etc/hosts || true
sed -i "/^127\.0\.0\.1\s/,+0s/\(\s$hostname\)\+\(\s\|$\)/\2/g" /etc/hosts || true
fi

# Set default "runlevel"
Expand Down
3 changes: 1 addition & 2 deletions rpm_spec/core-agent.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,7 @@ fi || :

%posttrans selinux
%selinux_relabel_post
%systemd_post qubes-relabel-root.service
%systemd_post qubes-relabel-rw.service
%systemd_post qubes-relabel-root.service qubes-relabel-rw.service
systemctl start selinux-autorelabel-mark.service
exit 0

Expand Down

0 comments on commit 0e22478

Please sign in to comment.