Debian Codegraph @

scripts/sbin/drbl-client-xfs-switch

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/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 [scip-shell system . . `[`. $# -ne 1 ]; then
21 echoscip-shell system . . echo. "$USAGE"
22 echoscip-shell system . . echo. "Example: use the following to use remote xfs service for clients"
23 echoscip-shell system . . echo. "$0 remote"
24 exit 1
25 fi
26 #
27 case "$switch" in
28 "remote")
29 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
30 echoscip-shell system . . echo. "Setting the remote xfs for clients..."
31 [scip-shell system . . `[`. "$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/nullscip-shell filesystem . . `/dev/null`.; lsscip-shell system . . ls. -d $drblroot/* 2>/dev/nullscip-shell filesystem . . `/dev/null`. |wcscip-shell system . . wc. -w|sedscip-shell system . . sed. -e "s/ //g")
35 # / 1 to make the result as integer.
36 client_no=$(echoscip-shell system . . echo. "scale=0; $client_no * $XFS_RATIO / 1" |bc -l)
37 [scip-shell system . . `[`. $client_no -lt 10 ] && client_no=10
38 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*[#]*[[:space:]]*client-limit[[:space:]]*=.*/client-limit = $client_no/" /etc/X11/fs/configscip-shell filesystem . . `/etc/X11/fs/config`.
39 # enable the xfs service with tcp
40 perlscip-shell system . . perl. -p -i -e "s/^.*no-listen = tcp.*/#no-listen = tcp/" /etc/X11/fs/configscip-shell filesystem . . `/etc/X11/fs/config`.
41 # restart xfs
42 /etc/init.d/xfsscip-shell filesystem . . `/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=$(basenamescip-shell system . . basename. $ihost)
48 font_server=$(grepscip-shell system . . grep. -e "$drblroot/$IP/etc" $drblroot/$IP/etc/fstab | awkscip-shell system . . awk. -F":" '{print $1}')
49 [scip-shell system . . `[`. -z "$font_server" ] && echoscip-shell system . . echo. "Failed to find the font server...Program terminated!" && exit 1
50 #
51 echoscip-shell system . . echo. -n "Setting the remote font server in XF86Config for client $IP..."
52 if [scip-shell system . . `[`. -f $ihost/etc/X11/XF86Config ]; then
53 # backup first
54 echoscip-shell system . . echo. "Editing XF86Config..."
55 cpscip-shell system . . cp. -f $ihost/etc/X11/XF86Config $ihost/etc/X11/XF86Config.drblsave
56 perlscip-shell system . . 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 stopscip-shell filesystem . . `/etc/init.d/xfs stop`."
61 fi
62 if [scip-shell system . . `[`. -f $ihost/etc/X11/XF86Config-4 ]; then
63 # backup first
64 cpscip-shell system . . cp. -f $ihost/etc/X11/XF86Config-4 $ihost/etc/X11/XF86Config-4.drblsave
65 perlscip-shell system . . 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 stopscip-shell filesystem . . `/etc/init.d/xfs stop`."
70 fi
71 if [scip-shell system . . `[`. -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 echoscip-shell system . . echo. "done!"
79 ;;
80 "local")
81 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
82 echoscip-shell system . . echo. "Setting the local xfs for clients..."
83 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
84 # Change the xfs setting in server, Default font server comes with client-limt = 10
85 client_no=10
86 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*[#]*[[:space:]]*client-limit[[:space:]]*=.*/client-limit = $client_no/" /etc/X11/fs/configscip-shell filesystem . . `/etc/X11/fs/config`.
87 perlscip-shell system . . perl. -p -i -e "s/^.*no-listen = tcp.*/no-listen = tcp/" /etc/X11/fs/configscip-shell filesystem . . `/etc/X11/fs/config`.
88 # restart xfs
89 /etc/init.d/xfsscip-shell filesystem . . `/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=$(basenamescip-shell system . . basename. $ihost)
97 echoscip-shell system . . echo. -n "Setting the local font server in XF86Config for client $IP..."
98 if [scip-shell system . . `[`. -f $ihost/etc/X11/XF86Config ]; then
99 cpscip-shell system . . cp. -f $ihost/etc/X11/XF86Config $ihost/etc/X11/XF86Config.drblsave
100 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*[^#]*[[:space:]]*FontPath[[:space:]]+\".*\".*/\tFontPath \"unix\/:$fs_port\"/" $ihost/etc/X11/XF86Config
101 fi
102 if [scip-shell system . . `[`. -f $ihost/etc/X11/XF86Config-4 ]; then
103 cpscip-shell system . . cp. -f $ihost/etc/X11/XF86Config-4 $ihost/etc/X11/XF86Config-4.drblsave
104 perlscip-shell system . . 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 restartscip-shell filesystem . . `/etc/init.d/xfs restart`."
109
110 echoscip-shell system . . echo. "done!"
111
112 ;;
113 *)
114 echoscip-shell system . . echo. "$USAGE"
115 esac
116 #
117 echoscip-shell system . . echo. "-------------------------------------------------------"
118 echoscip-shell system . . echo. "Since some config files are modified in template client, creating template tarball for DRBL SSI..."
119 drbl-gen-ssi-files