Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ install_exec syncthing/startstop-syncthing.sh "$DESTDIR$usr_sbindir/
install_data dbus-user-session/dbus.service "$DESTDIR$usr_libdir/systemd/user/dbus.service"
install_data dbus-user-session/dbus.socket "$DESTDIR$usr_libdir/systemd/user/dbus.socket"
install_symlink ../dbus.socket "$DESTDIR$usr_libdir/systemd/user/sockets.target.wants/dbus.socket"
for f in post-pdist/*; do
install_exec "$f" "$DESTDIR$usr_exec_prefix/libexec/post-pdist/$(basename "$f")"
for f in pdist/post-update.d/*; do
install_exec "$f" "$DESTDIR$usr_exec_prefix/libexec/pdist/post-update.d/$(basename "$f")"
done

postinstall
Expand Down
29 changes: 29 additions & 0 deletions pdist/pdist
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ BEGIN {

use constant {
DISTFILE => '/root/Distfile', # read FILES,HOSTS,EXCEPTS here
POST_UPDATE_DIR => '/usr/libexec/pdist/post-update.d', # run scripts from here after a successful update
};

our $PID=$$;
Expand Down Expand Up @@ -846,6 +847,27 @@ sub prog_update
}
}

sub run_post_update_scripts {
my $hostname = hostname;

unless (opendir DIR, POST_UPDATE_DIR) {
$! == 2 and return; # ENOENT: no scripts installed
die POST_UPDATE_DIR . ": $!\n";
}
my @scripts = sort grep /^[0-9][-.0-9A-Za-z_]*$/, readdir DIR;
closedir DIR;

for my $script (@scripts) {
my $path = POST_UPDATE_DIR . '/' . $script;
-f $path or next; # ignore subdirectories
$quiet or warn "$hostname: executing $path\n";
system $path;
$? == -1 and die "$path: $!\n";
$? & 127 and die sprintf "%s: killed by signal %d\n", $path, $? & 127;
$? and die sprintf "%s: exit status %d\n", $path, $? >> 8;
}
}

sub prog_client
{
my ($master,$port)=@_;
Expand Down Expand Up @@ -944,6 +966,8 @@ sub prog_client
unlink ($master_index);
unlink ($requestfile);

$fileop_noop or run_post_update_scripts();

if ($post_command) {
$verbose and warn "$hostname: executing $post_command\n";
$fileop_noop or system $post_command;
Expand Down Expand Up @@ -1179,6 +1203,11 @@ usage: $0 cmd [options]
update want-indexfile [tarfile] # update to want-indexfile using tar
client master-name port [--msg-prefix] xxx # client server

# after a successful update the client runs all scripts in
# @{[POST_UPDATE_DIR]}/ whose name starts with a digit, in name
# order, and aborts on the first one which fails. --post-command, if
# given, runs afterwards.

# high level

push [options] client ... # update client with our snapshot
Expand Down
3 changes: 1 addition & 2 deletions pdist/pdist-bootcheck
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fi

if [ "$need_async_pdist" ]; then
systemd-run --unit pdist-async-update --service-type=simple --remain-after-exit \
-- bash -c 'netcat $(distmaster) 237 ; make-automaps'
-- bash -c 'netcat $(distmaster) 237'
echo triggered background update
elif [ "$need_pdist_and_reboot" ]; then
if [[ -e /var/cache/updatecheck.reboot-triggered ]]; then
Expand All @@ -46,7 +46,6 @@ elif [ "$need_pdist_and_reboot" ]; then
sync /
while true; do sleep 5; echo "System update in progress. Please be patient..."; done &
netcat $(distmaster) 237
make-automaps
mxgrub default
systemctl start reboot.target --job-mode=replace-irreversibly
fi
2 changes: 1 addition & 1 deletion pdist/pdistd@.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ CollectMode=inactive-or-failed

[Service]
StandardOutput=socket
ExecStart=bash -c "read ip host <<< $(getent hosts ${REMOTE_ADDR}) ; echo update in progess... ; pdist push $host --timeout 600 --set-pdist-status --post-command /usr/libexec/post-pdist/post-pdist"
ExecStart=bash -c "read ip host <<< $(getent hosts ${REMOTE_ADDR}) ; echo update in progess... ; pdist push $host --timeout 600 --set-pdist-status"
3 changes: 3 additions & 0 deletions pdist/post-update.d/0005-make-automaps
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

/usr/sbin/make-automaps
9 changes: 0 additions & 9 deletions post-pdist/post-pdist

This file was deleted.