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 *
RevLine 
[23155]1#!/bin/sh
[24149]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.
[23155]10
[25609]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
[24125]16set -e
[24165]17cd /
[24125]18
[25536]19addgroups="sudo admin lpadmin adm fuse cdrom floppy audio video plugdev scanner dialout lp"
[24125]20daemons="$(/usr/sbin/policy-rc.d --daemons)"
21
22# Setup
23
24session=$(schroot -c login -b)
[25606]25cleanup() {
26    # Teardown
27
[25716]28    # Remove file from above.
29    # (This also gets nuked in reactivate, but be paranoid)
30    rm -f /tmp/ticketenv
31
[25606]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
[24230]39sch() { schroot -r -c "$session" -- "$@"; }          # Run in the chroot
40schq() { schroot -q -r -c "$session" -- "$@"; }      # Run in the chroot quietly
[24232]41schr() { schroot -r -c "$session" -u root -- "$@"; } # Run in the chroot as root
[24228]42
[24125]43for group in $addgroups; do
[25536]44    schr env NSS_NONLOCAL_IGNORE=ignore getent group "$group" >/dev/null 2>&1 && schr adduser "$USER" "$group"
[24125]45done
46
[24228]47schr touch /ClusterLogin
[24199]48
[24125]49for daemon in $daemons; do
[24228]50    schr invoke-rc.d "$daemon" start || [ $? = 100 ]
[24125]51done
52
[24228]53schr rm /etc/debian_chroot
[24125]54
[24278]55# Deter people from thinking they can use /home as persistant storage
56# by punting it
57schr rm -rf /home
58
[25187]59# Fix up mtab so that df and friends work correctly
[25275]60schr sed -i "s| /var/lib/schroot/mount/${session}/| /|" /etc/mtab
[25187]61
[24125]62# Run the session
63#
[25727]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
[24125]66
[25716]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
[24149]72set +e
73
[24165]74cd
[25671]75schroot -c "$session" -r -p -- /usr/lib/debathena-reactivate/session-wrapper "$@"
[24165]76cd /
[24149]77
Note: See TracBrowser for help on using the repository browser.