source: trunk/debathena/config/reactivate/debian/snapshot-run @ 25727

Revision 25727, 2.2 KB checked in by jdreed, 12 years ago (diff)
In reactivate: * Cleanup from r24057, where we had to special-case quickstations via su-error and sudo-error, and cleanup those conffiles in a Debian-esque way * Add a trailing NUL to the end of sudo-warning to workaround a bug in sudo 1.8.3p1 (fixed upstream, but not in Precise)
  • Property svn:executable set to *
Line 
1#!/bin/sh
2#
3# snapshot-run PROGRAM [ARGS]
4# Create an Athena login snapshot, run PROGRAM within it, and clean up
5# the snapshot.
6#
7# This script is run as the user who is logging in, usually as a wrapper
8# around their Xsession or shell. You probably want to run reactivate
9# immediately afterwards, as root.
10
11if [ -e /var/run/debathena-inhibit-dbus-helper ]; then
12    logger -p user.notice -t reactivate "debathena-inhibit-dbus-helper still exists in snapshot-run (shouldn't happen)"
13    rm /var/run/debathena-inhibit-dbus-helper
14fi
15
16set -e
17cd /
18
19addgroups="sudo admin lpadmin adm fuse cdrom floppy audio video plugdev scanner dialout lp"
20daemons="$(/usr/sbin/policy-rc.d --daemons)"
21
22# Setup
23
24session=$(schroot -c login -b)
25cleanup() {
26    # Teardown
27
28    # Remove file from above.
29    # (This also gets nuked in reactivate, but be paranoid)
30    rm -f /tmp/ticketenv
31
32    for daemon in $daemons; do
33        schr invoke-rc.d "$daemon" stop || [ $? = 100 ]
34    done
35
36    schroot -c "$session" -e
37}
38trap 'cleanup' EXIT
39sch() { schroot -r -c "$session" -- "$@"; }          # Run in the chroot
40schq() { schroot -q -r -c "$session" -- "$@"; }      # Run in the chroot quietly
41schr() { schroot -r -c "$session" -u root -- "$@"; } # Run in the chroot as root
42
43for group in $addgroups; do
44    schr env NSS_NONLOCAL_IGNORE=ignore getent group "$group" >/dev/null 2>&1 && schr adduser "$USER" "$group"
45done
46
47schr touch /ClusterLogin
48
49for daemon in $daemons; do
50    schr invoke-rc.d "$daemon" start || [ $? = 100 ]
51done
52
53schr rm /etc/debian_chroot
54
55# Deter people from thinking they can use /home as persistant storage
56# by punting it
57schr rm -rf /home
58
59# Fix up mtab so that df and friends work correctly
60schr sed -i "s| /var/lib/schroot/mount/${session}/| /|" /etc/mtab
61
62# Run the session
63#
64# We wrap the target command in a session-wrapper so that it can run
65# initgroups(3), which puts users back in the groups we added them to
66
67# Workaround for stupidity, see #928 for details
68# Remove this once we're running pam-afs-session 2.4
69# Run this inside the "set -e" block so it'll fail if necessary
70echo "KRB5CCNAME=$KRB5CCNAME" >| /tmp/ticketenv
71
72set +e
73
74cd
75schroot -c "$session" -r -p -- /usr/lib/debathena-reactivate/session-wrapper "$@"
76cd /
77
Note: See TracBrowser for help on using the repository browser.