source: lliurex-rpi-packages/trunk/fuentes/ldm/ltsp/ltsp-bindmounts @ 2328

Last change on this file since 2328 was 2328, checked in by kbut, 3 years ago

add new package

  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#! /bin/sh
2
3set -e
4
5# Gracefully exit if ltsp_chroot file is not present
6test -f /etc/ltsp_chroot || exit 0
7
8bind_mounts () {
9    # set defaults
10    test -z "$tmpfs_dir" && tmpfs_dir=/var/lib/ltsp-client-setup
11    mount -t tmpfs -o mode=0755 tmpfs $tmpfs_dir
12    bind_missing=""
13    # preserve directory structure
14    for d in $rw_dirs ; do
15        if [ -d "$d" ]; then
16            cd $tmpfs_dir
17            tar --no-recursion -cpf - $(find $d -type d 2> /dev/null) 2> /dev/null | tar xpf -
18            mount --bind $tmpfs_dir/$d $d
19        else
20            bind_missing="$bind_missing $d"
21        fi
22    done
23    # copy contents into tmpfs
24    for d in $copy_dirs $temp_copy_dirs; do
25        if [ -d "$d" ]; then
26            cd $tmpfs_dir
27            tar -cpf - $d 2> /dev/null | tar xpf -
28            mount --bind $tmpfs_dir/$d $d
29        else
30            bind_missing="$bind_missing $d"
31        fi
32    done
33    # mount one file on top of another
34    for f in $bindfiles ; do
35        if [ -e "$f" ]; then
36            mkdir -p "$(dirname $tmpfs_dir/$f)"
37            cp $f $tmpfs_dir/$f
38            mount --bind $tmpfs_dir/$f $f
39        else
40            bind_missing="$bind_missing $f"
41        fi
42    done
43    if [ -n "$bind_missing" ]; then
44        echo "note: ltsp: missing files or directories for bind mounting: $bind_missing"
45    fi
46}
47
48bind_unmounts() {
49    for dir in $temp_copy_dirs; do
50        umount $dir
51        rm -rf $tmpfs_dir/${dir#/}
52    done
53}
54
55# tmpfs/bind directories that get mounted with only directory structure
56# preserved
57
58rw_dirs="/var/lib/xkb /var/log /var/spool /var/tmp /tmp /etc/console-setup /var/lib/pulse /var/lib/dbus /var/cache/hald /var/cache/ltsp /var/lib/urandom"
59
60# tmpfs/bind directories that get mounted with directory structure and data
61# copied
62copy_dirs="/root /home /var/cache/ltsp-localapps /etc/rsyslog.d /etc/cups /media /etc/cron.d /etc/udev/rules.d"
63
64# tmpfs/bind files that mounted on top of other files
65bindfiles="/etc/network/interfaces /etc/hostname /etc/hosts /etc/syslog.conf /etc/fstab /etc/resolv.conf /etc/X11/xorg.conf /etc/passwd /etc/group /etc/localtime"
66
67. /usr/share/ltsp/ltsp-init-common
68
69# override variables if configured via lts.conf or ltsp_config
70[ -n "$LTSP_RW_DIRS" ] && rw_dirs="$LTSP_RW_DIRS"
71[ -n "$LTSP_RW_DIRS_EXTRA" ] && rw_dirs="$rw_dirs $LTSP_RW_DIRS_EXTRA"
72[ -n "$LTSP_COPY_DIRS" ] && copy_dirs="$LTSP_COPY_DIRS"
73[ -n "$LTSP_COPY_DIRS_EXTRA" ] && copy_dirs="$rw_dirs $LTSP_COPY_DIRS_EXTRA"
74[ -n "$LTSP_BINDFILES" ] && bindfiles="$LTSP_BINDFILES"
75[ -n "$LTSP_BINDFILES_EXTRA" ] && bindfiles="$rw_dirs $LTSP_BINDFILES_EXTRA"
76
77bind_mounts
Note: See TracBrowser for help on using the repository browser.