source: trunk/debathena/config/reactivate/debian/reactivate @ 25626

Revision 25626, 1.9 KB checked in by jdreed, 12 years ago (diff)
In reactivate: * Set the time in reactivate, because NTP apparently can't (Trac: #749)
  • Property svn:executable set to *
Line 
1#!/bin/bash
2#
3# Cleans up after a login snapshot to make the machine ready for the
4# next login.
5#
6# This script may choose to reboot the machine in order to clear
7# user processes or processes using the login snapshot, although
8# that circumstance should be fairly rare.
9
10print_processes_info() {
11  echo "BEGIN PRINT_PROCESS_INFO"
12  pstree -alcnpu
13  ps eauxwww
14  schroot --list -a
15  mount
16  LC_ALL=C lsof -b +c 0 -w
17  echo "END PRINT_PROCESS_INFO"
18}
19
20set -e
21exec >>/var/log/athena-reactivate 2>&1
22
23# Stop any daemons that were specifically started inside the
24# chroot
25for daemon in $daemons; do
26  invoke-rc.d $daemon restart || [ $? = 100 ]
27done
28
29# schroot has already attempted to kill everything inside the chroot,
30# fairly thoroughly. Our job here is to determine if anything is stuck
31# after a kill -9, and reboot.
32for i in /var/lib/schroot/mount/*; do
33  if mountpoint -q "$i"; then
34    touch /var/run/reboot-required
35    echo "rebooting due to active mountpoint $i"
36    print_processes_info
37    break
38  fi
39done
40if [ -n "$USER" -a "$USER" != root ]; then
41  if pgrep -u "$USER"; then
42    echo "rebooting due to live user processes"
43    print_processes_info
44    touch /var/run/reboot-required
45  fi
46fi
47
48# Cleanup our ticketenv hack
49# Make sure nobody was evil
50chattr -f -i /tmp/ticketenv || :
51# If you made a directory and stored files there, too bad
52rm -rf /tmp/ticketenv
53
54# If either we or an updated package wanted to reboot, now is a
55# perfectly good time to do so -- auto-update is inhibited during a
56# login session.
57if [ -e /var/run/reboot-required ]; then
58  echo "Reboot initiated at $(date)"
59  reboot
60fi
61
62# Trac: #749
63service ntp stop
64gettime -s time.mit.edu
65service ntp start
66
67
68# Yes, we want this here.  A reboot will take care of cleaning up
69# /var/run anyway, and since dbus is essential to rebooting these
70# days, we don't want to risk things magically getting spawned inside
71# a crippled chroot
72rm /var/run/debathena-inhibit-dbus-helper
Note: See TracBrowser for help on using the repository browser.