Debian Codegraph @

scripts/sbin/drbl-client-xfs-switch

raw symbols SCIP
1 #!/bin/bash
2 # Written by Steven Shiau <[email protected]> to use in DRBL for RedHat
3 # License: GPL
4 #
5 # set the iptables NAT
6 # clean the old tables
7
8 # Load DRBL setting and functions
9 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
10 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
11
12 #
13 check_if_root
14
15 # main
16 USAGE="Usage: $0 {local|remote}"
17 switch=$1
18
19 #
20 if [ $# -ne 1 ]; then
21 echo "$USAGE"
22 echo "Example: use the following to use remote xfs service for clients"
23 echo "$0 remote"
24 exit 1
25 fi
26 #
27 case "$switch" in
28 "remote")
29 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
30 echo "Setting the remote xfs for clients..."
31 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
32 # Change the xfs setting in server
33 # set the client_no first, minimum 10.
34 client_no=$(unalias ls 2> /dev/null; ls -d $drblroot/* 2>/dev/null |wc -w|sed -e "s/ //g")
35 # / 1 to make the result as integer.
36 client_no=$(echo "scale=0; $client_no * $XFS_RATIO / 1" |bc -l)
37 [ $client_no -lt 10 ] && client_no=10
38 perl -p -i -e "s/^[[:space:]]*[#]*[[:space:]]*client-limit[[:space:]]*=.*/client-limit = $client_no/" /etc/X11/fs/config
39 # enable the xfs service with tcp
40 perl -p -i -e "s/^.*no-listen = tcp.*/#no-listen = tcp/" /etc/X11/fs/config
41 # restart xfs
42 /etc/init.d/xfs restart
43
44 # change the XF86Config file in client, for MDK it's XF86Config-4,
45 for ihost in $drblroot/*; do
46 # try to get the font server
47 IP=$(basename $ihost)
48 font_server=$(grep -e "$drblroot/$IP/etc" $drblroot/$IP/etc/fstab | awk -F":" '{print $1}')
49 [ -z "$font_server" ] && echo "Failed to find the font server...Program terminated!" && exit 1
50 #
51 echo -n "Setting the remote font server in XF86Config for client $IP..."
52 if [ -f $ihost/etc/X11/XF86Config ]; then
53 # backup first
54 echo "Editing XF86Config..."
55 cp -f $ihost/etc/X11/XF86Config $ihost/etc/X11/XF86Config.drblsave
56 perl -p -i -e "s/^[[:space:]]*[^#]*[[:space:]]*FontPath[[:space:]]+\".*\".*/\tFontPath \"tcp\/$font_server:$fs_port\"/" $ihost/etc/X11/XF86Config
57 # del the xfs service to clients
58 drbl-client-service -h $IP xfs del
59 # stop the xfs service in clients
60 drbl-doit -h $IP "/etc/init.d/xfs stop"
61 fi
62 if [ -f $ihost/etc/X11/XF86Config-4 ]; then
63 # backup first
64 cp -f $ihost/etc/X11/XF86Config-4 $ihost/etc/X11/XF86Config-4.drblsave
65 perl -p -i -e "s/^[[:space:]]*[^#]*[[:space:]]*FontPath[[:space:]]+\".*\".*/\tFontPath \"tcp\/$font_server:$fs_port\"/" $ihost/etc/X11/XF86Config-4
66 # del the xfs service to clients
67 drbl-client-service -h $IP xfs del
68 # stop the xfs service in clients
69 drbl-doit -h $IP "/etc/init.d/xfs stop"
70 fi
71 if [ -f $ihost/etc/X11/XF86Config -a -f $ihost/etc/X11/XF86Config-4 ]; then
72 # we need xfs, otherwise firstboot will fail to detect successfully, because no xfs service running locally
73 # so keep the xfs service to client
74 drbl-client-service -h $IP xfs add
75 fi
76 done
77 #
78 echo "done!"
79 ;;
80 "local")
81 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
82 echo "Setting the local xfs for clients..."
83 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
84 # Change the xfs setting in server, Default font server comes with client-limt = 10
85 client_no=10
86 perl -p -i -e "s/^[[:space:]]*[#]*[[:space:]]*client-limit[[:space:]]*=.*/client-limit = $client_no/" /etc/X11/fs/config
87 perl -p -i -e "s/^.*no-listen = tcp.*/no-listen = tcp/" /etc/X11/fs/config
88 # restart xfs
89 /etc/init.d/xfs restart
90
91 # add the xfs service to clients
92 drbl-client-service xfs add
93 # change the XF86Config file in client, for MDK it's XF86Config-4,
94 # backup first
95 for ihost in $drblroot/*; do
96 IP=$(basename $ihost)
97 echo -n "Setting the local font server in XF86Config for client $IP..."
98 if [ -f $ihost/etc/X11/XF86Config ]; then
99 cp -f $ihost/etc/X11/XF86Config $ihost/etc/X11/XF86Config.drblsave
100 perl -p -i -e "s/^[[:space:]]*[^#]*[[:space:]]*FontPath[[:space:]]+\".*\".*/\tFontPath \"unix\/:$fs_port\"/" $ihost/etc/X11/XF86Config
101 fi
102 if [ -f $ihost/etc/X11/XF86Config-4 ]; then
103 cp -f $ihost/etc/X11/XF86Config-4 $ihost/etc/X11/XF86Config-4.drblsave
104 perl -p -i -e "s/^[[:space:]]*[^#]*[[:space:]]*FontPath[[:space:]]+\".*\".*/\tFontPath \"unix\/:$fs_port\"/" $ihost/etc/X11/XF86Config-4
105 fi
106 done
107 #
108 drbl-doit "/etc/init.d/xfs restart"
109
110 echo "done!"
111
112 ;;
113 *)
114 echo "$USAGE"
115 esac
116 #
117 echo "-------------------------------------------------------"
118 echo "Since some config files are modified in template client, creating template tarball for DRBL SSI..."
119 drbl-gen-ssi-files