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

Revision 24492, 1.5 KB checked in by jdreed, 14 years ago (diff)
In reactivate: * Add "lp" to the list of groups we add the user to, to support all those cluster machines with parallel port printers attached (Trac #92)
  • 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
[24125]11set -e
[24165]12cd /
[24125]13
[24492]14addgroups="admin lpadmin adm fuse cdrom floppy audio video plugdev scanner dialout lp"
[24125]15daemons="$(/usr/sbin/policy-rc.d --daemons)"
16
17# Setup
18
19session=$(schroot -c login -b)
[24230]20sch() { schroot -r -c "$session" -- "$@"; }          # Run in the chroot
21schq() { schroot -q -r -c "$session" -- "$@"; }      # Run in the chroot quietly
[24232]22schr() { schroot -r -c "$session" -u root -- "$@"; } # Run in the chroot as root
[24228]23
[24125]24for group in $addgroups; do
[24228]25    schr getent group "$group" >/dev/null 2>&1 && schr adduser "$USER" "$group"
[24125]26done
27
[24228]28schr sed -i "/su-error/d" "/etc/pam.d/su.debathena"
[24125]29
[24228]30schr touch /ClusterLogin
[24199]31
[24125]32for daemon in $daemons; do
[24228]33    schr invoke-rc.d "$daemon" start || [ $? = 100 ]
[24125]34done
35
[24228]36schr rm /etc/debian_chroot
[24125]37
[24278]38# Deter people from thinking they can use /home as persistant storage
39# by punting it
40schr rm -rf /home
41
[24125]42# Run the session
43#
[24149]44# We wrap the target command in sudo because it runs initgroups(3)
[24125]45# /after/ being chrooted, which puts users back in the groups we
46# added them to
47
[24149]48set +e
49
[24165]50cd
[24149]51schroot -c "$session" -r -p -- sudo -E -u "$USER" -- "$@"
[24165]52cd /
[24149]53
[24125]54# Teardown
55
56for daemon in $daemons; do
[24228]57    schr invoke-rc.d "$daemon" stop || [ $? = 100 ]
[24125]58done
59
60schroot -c "$session" -e
Note: See TracBrowser for help on using the repository browser.