This file is indexed.

/usr/sbin/drbl-live is in drbl 2.20.11-4.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
#!/bin/bash
# Author: Steven Shiau <steven _at_ nchc org tw>
# License: GPL

#
DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"

. $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
[ -e /etc/drbl/drbl-ocs.conf ] && . /etc/drbl/drbl-ocs.conf
[ -e $DRBL_SCRIPT_PATH/sbin/ocs-functions ] && . $DRBL_SCRIPT_PATH/sbin/ocs-functions

# Load the config in ocs-live.conf. This is specially for DRBL/Clonezilla live. It will overwrite some settings of drbl-ocs.conf, such as $DIA...
[ -e "/etc/ocs/ocs-live.conf" ] && . /etc/ocs/ocs-live.conf

# functions
USAGE() {
    echo "To start, restart or stop DRBL service in DRBL Live environment."
    echo "Usage:"
    echo "$0 [OPTION] {start|stop|restart}"
    echo "OPTION:"
    echo "-b, -batch, --batch          Run program in batch mode, i.e. without any prompt or wait for pressing enter key.  //NOTE// You have to use '-batch' instead of '-b' when you want to use it in the boot parameters. Otherwise the program init on system will honor '-b', too."
    echo "-c, -client-no NO             Assign the client number as NO for each network card connected to clients"
    echo "-p, --prepare-ocsroot         Prepare clonezilla image home dir also."
    echo "-s, --skip-pause-in-the-end   Skip showing the messsage and pause in the end of execuation."
    echo "-n, --no-prompt-drbl-live     Assume it's running for drbl live. (This is normally only used for clonezilla server edition script ocs-srv-live in DRBL live mode)"
    echo "start   Start DRBL services now"
    echo "stop    Stop DRBL services now"
    echo "restart Restart DRBL services now"
    echo "Example: To start all DRBL services in this DRBL Live server"
    echo "$0 start"
}

# set locale for clients
set_locale_for_clients() {
  # Some of the code is referred to pakcage casper /usr/share/initramfs-tools/scripts/casper-bottom/14locales
  # We use the locale from server as the default one in client.
  if [ -e /etc/default/locale ]; then
      grep_file=/etc/default/locale
  elif [ -e /etc/environment ]; then # Old locales policy
      grep_file=/etc/environment
  fi
  if [ -n "${grep_file}" ]; then
      # use server's configured locale
      locale=$(grep -s 'LANG=' ${grep_file} | sed s/'LANG='// | tr -d '"' )
  fi
  if [ -z "$locale" ]; then
      # Set a default one
      locale=en_US.UTF-8
  fi
  LANG="${locale}"

  # write the setting in clients.
  for ih in $drblroot/*; do
    echo "LANG=${LANG}" > $ih/${grep_file}
  done
  echo "Since some config files are modified in template client, recreating template tarball for DRBL SSI..."
  drbl-gen-ssi-files
} # end of set_locale_for_clients
#
prep_live_system_for_drbl_clonezilla_clients(){
  # Sep/10/2015 Due to this /tmp/ or /dev/ missing issue, we switch to use live system for Clonezilla SE client
  # http://lists.freedesktop.org/archives/systemd-devel/2015-September/034175.html
  # Actually this method is easier and better for Clonezilla jobs.
  # (1) Prepre the Clonezilla SE client with live system
  # The kernel (Clonezilla-live-vmlinuz) and initrd (Clonezilla-live-initrd.img) from $LIVE_MEDIA will be linked as "DRBL-live-vmlinuz" and "DRBL-live-initrd.img" in drbl-ocs-live-prep
  drbl-ocs-live-prep -p $LIVE_MEDIA

  # (2) Update the network boot menu for DRBL client with live system
  # Prepare the keyboard and locales for DRBL clients
  if [ -n "$(printenv LC_ALL)" ]; then
    client_locale="$(printenv LC_ALL)"
  elif [ -n "$(printenv LANG)" ]; then
    client_locale="$(printenv LANG)"
  else
    # If both LC_ALL and LANG are not found, force to set en_US.UTF-8
    client_locale="en_US.UTF-8"
  fi
  if [ -e /etc/default/keyboard ]; then
    . /etc/default/keyboard
    client_kb_layout="$XKBLAYOUT"
    client_kb_model="$XKBMODEL"
    client_kb_variant="$XKBVARIANT"
    client_kb_options="$XKBOPTIONS"
  fi
  if [ -z "$client_kb_layout" ]; then
    # If no keybouard layout is found, set it as us.
    client_kb_layout=us
    # For the rest (model, variant or options they might be nothing.
  fi
  # We will make pxelinux config like this for DRBL client:
  # APPEND initrd=DRBL-live-initrd.img boot=live union=overlay username=drbl config components nomodeset quiet nosplash keyboard-layouts=NONE locales=en_US.UTF-8 drbl_live_noconfx ocs_daemonon="ssh" noprompt netboot=nfs nfsroot=192.168.7.254:/tftpboot/node_root/clonezilla-live/ dcs_put_dticons="no"

  PXE_CONF="$PXE_CONF_DEF"
  GRUB_CONF="$GRUB_EFINB_CONF_DEF"
  # TODO: find a better way to give different nfs_srv IP address if more than one available, so that clients can be grouped to different NFS server.
  live_nfs_srv="$(get-all-nic-ip -b | awk -F" " '{print $1}')"
  # Find the boot parameters from the server, and re-use it for client.
  # It maybe be customized by users, so we have to filter some more, like ocs_prerun*, and some will be added later, like "drbl_live_noconfx" so we force to remove it to avoid duplicated.
  # E.g:
  # BOOT_IMAGE=/live/vmlinuz initrd=/live/initrd.img boot=live union=overlay username=user config components nomodeset quiet vga=785 ip= net.ifnames=0  nosplash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1 keyboard-layouts=NONE locales=en_US.UTF-8 drbl_live_noconfx ocs_daemonon="ssh" ocs_prerun1="ifconfig eth0 192.168.120.3; route add default gw 192.168.120.254 eth0; ifconfig eth1 192.168.7.254 netmask 255.255.255.0; echo nameserver 8.8.8.8 > /etc/resolv.conf" ocs_prerun2="mount -t nfs 192.168.120.254:/home/partimag /home/partimag" ocs_prerun3="drbl-live --batch --skip-pause-in-the-end --no-prompt-drbl-live start" ocs_prerun5="perl -pi -e 's/timeout 70/timeout 10/' /tftpboot/nbi_img/pxelinux.cfg/default"
  cl_gp_boot_param="$(LC_ALL=C cat /proc/cmdline | filter_cl_gp_boot_param)"
  # Append those preseeding boot param we want for live system client
  cl_gp_boot_param="$cl_gp_boot_param hostname=drbl-client username=drbl \
keyboard-layouts=$client_kb_layout locales=$client_locale drbl_live_noconfx \
stick-to-pxe-srv ocs_daemonon=\"ssh\" noprompt netboot=nfs \
nfsroot=${live_nfs_srv}:$drbl_common_root/clonezilla-live/ \
dcs_put_dticons=\"no\""
  # This is for the boot parameters in grub config, i.e. those in the "linux" line, e.g.
  # linux vmlinuz-pxe boot=live union=overlay config components nomodeset quiet 
  boot_param_in_grub_cfg="DRBL-live-vmlinuz $cl_gp_boot_param"
  # This is the boot parameters for PXElinux config, i.e. those in the "append" line, e.g.
  # append initrd=/live/initrd.img boot=live union=overlay config components nomodeset quiet
  boot_param_in_pxe_cfg="initrd=DRBL-live-initrd.img $cl_gp_boot_param"

  override_opt_in_pxelinux_cfg_block drbl "$boot_param_in_pxe_cfg"
  override_opt_in_pxelinux_cfg_block -k drbl "DRBL-live-vmlinuz"
  override_opt_in_grub_efi_cfg_block drbl-client "$boot_param_in_grub_cfg"
  override_opt_in_grub_efi_cfg_block -i drbl-client "DRBL-live-initrd.img"

} # end of prep_live_system_for_drbl_clonezilla_clients
#
start_drbl_live() {
  if [ "$prompt_drbl_live" = "yes" ]; then
    [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
    echo "$msg_this_is_for_drbl_server_not_for_clonezilla_server_edition"
    [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
    echo "$msg_are_u_sure_u_want_to_continue"
    echo -n "[Y/n] "
    read drbl_live_ans
    case "$drbl_live_ans" in
       n|N|[nN][oO]) echo "$msg_program_stop" 
                     exit 1 ;;
       *) echo "$msg_ok_let_do_it" ;;
    esac
  fi
  
  # config network first:
  config_drbl_live_network
  
  #
  if  [ "$prepare_ocsroot" = "yes" ]; then
     echo "Preparing clonezilla image home dir..."
     prep-ocsroot --skip-ocsroot-mountpoint-chk  # will check later to avoid the exit is only for prep-ocsroot program, not for this $0.
     check_if_ocsroot_a_mountpoint
  fi
  
  #
  echo "$msg_delimiter_star_line"
  echo $msg_now_continue_to_run_drblpush
  echo $msg_this_might_take_several_minutes
  if [ "$ocs_batch_mode" != "on" ]; then
    echo -n $msg_press_enter_to_continue
    read
  fi

  # Make a tag in client's root to mark this is drbl-live system. Since this is live system, we do not have to clean it later.
  get_live_media_mnt_point
  if [ -z "$LIVE_MEDIA" ]; then
    echo "///WARNING/// filesystem.squashfs not found! No idea where is LIVE_MEDIA!!!"
  fi
  echo "Live media is in $LIVE_MEDIA"
  echo "This is drbl live system." > $drbl_common_root/drbl_ssi/drbl-live-system.txt
  cat $LIVE_MEDIA/DRBL-Live-Version >> $drbl_common_root/drbl_ssi/drbl-live-system.txt
  
  # Before we run drblpush, we have to remove the services we put only for DRBL live server when creating drbl live. This will avoide those to be copied to SSI template tarball. Since these services are one-time use only for server during booting.
  rm -f /etc/rcS.d/*kbd-conf
  rm -f /etc/rcS.d/*Forcevideo-drbl-live 

  # Before running drblpush, first we add a group for the autologin accounts
  if [ -z "$(grep -E "^$autologin_group:" /etc/group)" ]; then
    groupadd "$autologin_group"
  fi
  
  # Now we can add the group "$autologin_group" to sudo
  if [ -e /etc/sudoers -a -x /usr/sbin/xfsm-shutdown-helper ]; then
    if [ -z "$(grep -E "^%$autologin_group ALL=NOPASSWD:.*xfsm-shutdown-helper" /etc/sudoers)" ]; then
      chmod u+w /etc/sudoers
      echo "# Added by DRBL" >> /etc/sudoers
      echo "%$autologin_group ALL=NOPASSWD:/usr/sbin/xfsm-shutdown-helper" >> /etc/sudoers
      chmod u-w /etc/sudoers
    fi
  fi
  
  # 2015/Sep/14 We have update the use_run_in_initrd and use_dev_pts_in_initrd by default to fit that in Sid, therefore comment this.
  # Run mknic-nbi again. Because we run mknic-nbi in the chroot when creating DRBL live. However, the variable use_run_in_initrd and use_dev_pts_in_initrd in initramfs' /etc/linuxrc.conf (i.e. "/usr/lib/mkpxeinitrd-net/initrd-skel/etc/linuxrc.conf") need to be updated in the run time.
  #echo
  #echo "Updating the initramfs for PXE clients..."
  #mknic-nbi -p 1
  
  prep_live_system_for_drbl_clonezilla_clients

  # 1st we load $client_no_per_NIC and $autologin_passwd_opt from the ocs-live-hook.conf when creating DRBL live.
  # However, later if client_no_per_NIC is assigned in boot parameter or "-c" option, it will be override.
  . $drbl_setup_path/files/ocs/live-hook/ocs-live-hook.conf

  # ocs_client_no_per_NIC is read from /etc/ocs/ocs-live.conf, which might be from boot parameter, or is assigned by this program with option "-c"
  if [ -n "$ocs_client_no_per_NIC" ]; then
    if [ -n "$(grep -Ew "^client_no_per_NIC=.*" /etc/ocs/ocs-live.conf)" ]; then
      LC_ALL=C perl -pi -e "s/^client_no_per_NIC=.*/client_no_per_NIC=$ocs_client_no_per_NIC/g" /etc/ocs/ocs-live.conf
    else
      echo "client_no_per_NIC=$ocs_client_no_per_NIC" >> /etc/ocs/ocs-live.conf
    fi
  fi
  # Now load $client_no_per_NIC for later use
  . /etc/ocs/ocs-live.conf
  
  # run drblpush again so that the network interface can be updated. Maybe there is new ethx.
  yes "" | drblpush -i -r 1 -z 1 --not-add-start-drbl-srvi --skip-drbl-ocs-live-prep -p $client_no_per_NIC

  # The override from drbl live system should be removed. It's autologin for Live system, not for drbl client
  rm -rf $drbl_common_root/etc/systemd/system/getty\@tty*
  rm -rf $drbl_common_root/etc/systemd/system/serial-getty\@ttyS*
  rm -rf $drblroot/*/etc/systemd/system/getty\@tty*
  rm -rf $drblroot/*/etc/systemd/system/serial-getty\@ttyS*

  # Since we use Clonezilla box or live system for clients OS when doing Clonezilla jobs, they all listen to the boot parameters
  # Therefore here we change ocs_client_trig_type as proc-cmdline to make drbl-ocs run a little bit faster.
  perl -pi -e "s/^ocs_client_trig_type=.*/ocs_client_trig_type=proc-cmdline/g" /etc/drbl/drbl-ocs.conf
  
  echo "$msg_delimiter_star_line"
  if [ "$limit_pxe_drbl_client" = "yes" ]; then
    # modify dhcpd.conf, provide IP address to PXE/Etherboot/DRBL client only
    echo "Modifying dhcpd.conf, now only PXE/Etherboot/DRBL client can lease IP address from this server..."
    perl -pi -e 's/^([[:space:]]*)#[[:space:]]*(allow members of "DRBL-Client";)/$1$2/g' $DHCPDCONF_DIR/dhcpd.conf
  else
    echo "Modifying dhcpd.conf, now ANY client, not only PXE/Etherboot/DRBL client, can lease IP address from this server..."
    perl -pi -e 's/^([[:space:]]*)#*[[:space:]]*(allow members of "DRBL-Client";)/$1#$2/g' $DHCPDCONF_DIR/dhcpd.conf
  fi
  
  echo "$msg_delimiter_star_line"
  echo "Enable auto login for drbl clients..."
  # enable autologin
  case "$autologin_passwd_opt" in
    "random")
      make_random_password $password_opt
      passwd_autologin="$random_password"
      ;;
    *)
      passwd_autologin="$passwd_autologin_def"
      ;;
  esac
  drbl-login-switch -a --no_nis_update -p "${passwd_autologin}"
  
  # Add the auto login accounts in every client so that we can add them to the group "autologin"
  echo -n "Adding the auto login accounts to the group $autologin_group..."
  for ihost in `get-client-ip-list`; do
    iaccount="$(get_existing_autologin_account $ihost)"
    adduser $iaccount $autologin_group &>/dev/null
    echo -n "."
  done
  echo " done!"
  
  echo "$msg_delimiter_star_line"
  # turn on tcpwrapper
  echo "Setting /etc/hosts.allow..."
  mv -f /etc/hosts.allow /etc/hosts.allow.orig
  client_IP_list="$(get-client-ip-list)"
  client_IP_list="$(echo $client_IP_list)"   # convert to 1 line
  client_IP_list_ar=( $client_IP_list )  # put it in an array
  # We can not list too long in hosts.allow, so put 20 elements in a line.
  nloop="$(echo "scale=0; ${#client_IP_list_ar[@]}/20" | bc -l )"
  echo "# Created by drbl-live" > /etc/hosts.allow
  for i in `seq 1 $nloop`; do
    istart="$(echo "scale=0; 20*$((i-1))" | bc -l)"
    iend="$(echo "scale=0; 20*$((i-1))+19" | bc -l)"
    echo -n "ALL: " >> /etc/hosts.allow
    for j in `seq $istart $iend`; do
      echo -n "${client_IP_list_ar[j]} " >> /etc/hosts.allow
    done
    echo >> /etc/hosts.allow
  done
  
  # set locales for clients.
  set_locale_for_clients
  
  #
  echo "Start all DRBL related services by running 'drbl-all-service start'..."
  drbl-all-service start
  
  # Now the YP service is up, we can update YP data.
  make -C /var/yp
  
  #
  echo "$msg_delimiter_star_line"
  echo "$msg_done!"
  
  if  [ "$pause_in_the_end" = "yes" ]; then
    [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
    echo "$msg_all_set_you_can_turn_on_clients"
    [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
    echo -n $msg_press_enter_to_continue
    # This is a weird problem about tftpd-hpa when it is restared in 'drbl-all-service start' in the above. It's:
    # -------
    # /etc/init.d/tftpd-hpa restart
    # echo -n "press key... "
    # read
    # -------
    # and we always get such an error when running it:
    # -------
    # Restarting HPA's tftpd: in.tftpd.
    # press key... ./td: line 4: read: read error: 0: Resource temporarily unavailable
    # -------
    # Therefore we use < /dev/stdin to avoid tihs.
    read dummy_var < /dev/stdin
  fi
} # end of start_drbl_live
#
stop_drbl_live() {
  # block all the clients.
  mv -f /etc/hosts.allow /etc/hosts.allow.orig2
  echo "# Disabled by drbl-live" > /etc/hosts.allow
  
  # stop and remove all services
  echo "Stop DRBL service.."
  drbl-all-service stop
  echo "Removing DRBL-related services..."
  drbl-all-service del
  #
  echo "$msg_delimiter_star_line"
  echo "$msg_done!"
  echo -n $msg_press_enter_to_continue
  read
} # end of stop_drbl_live


#################
##### MAIN ######
#################
check_if_root

#
ask_and_load_lang_set

# Default settings.
prepare_ocsroot="no"
pause_in_the_end="yes"
prompt_drbl_live="yes"
autologin_group="autologin"
#
while [ $# -gt 0 ]; do
  case "$1" in
    -b|-batch|--batch)
            ocs_batch_mode="on"
	    shift;;
    -c|-client-no)
            shift
            if [ -z "$(echo $1 |grep ^-.)" ]; then
              # skip the -xx option, in case 
              ocs_client_no_per_NIC="$1"
              shift
            fi
            ;;
    -p|--prepare-ocsroot)
            prepare_ocsroot="yes"
            shift ;;
    -s|--skip-pause-in-the-end)
            pause_in_the_end="no"
            shift ;;
    -n|--no-prompt-drbl-live)
            prompt_drbl_live="no"
            shift ;;
    -*)     echo "${0}: ${1}: invalid option" >&2
            USAGE >& 2
            exit 2 ;;
    *)      break ;;
  esac
done

switch=$1
#
if [ -z "$switch" ]; then
  USAGE
  exit 1
fi

#
if ! is_boot_from_live; then
  [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
  echo "This command $0 is used in DRBL Live environment only!"
  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
  echo "$msg_program_stop"
  exit 1
fi

case "$switch" in
   "start"|"restart") start_drbl_live ;;
   "stop")            stop_drbl_live ;;
esac