Class: Roebe::SimpleBootScript

Inherits:
Base show all
Defined in:
lib/roebe/classes/simple_boot_script.rb

Overview

Roebe::SimpleBootScript

Constant Summary

Constants inherited from Base

Base::COLOURS, Base::HOME_DIRECTORY_OF_USER_X, Base::N, Base::NAMESPACE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#actions, #append_this_onto_that_file, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #burlywood, #call_next, #chdir, #cheerful_guy, #cliner, #complex_esystem, #convert_global_env, #copy_directory, #copy_file, #cornflowerblue, #create_directory, #crimson, #current_month?, #current_time?, #current_year?, #cyan, #darkcyan, #darkgreen, #darkkhaki, #darkslateblue, #deeppink, #delete_symlink, #do_not_use_the_base_colours, #do_use_the_base_colours, #e, #ecomment, #editor_to_use?, #efancy, #eimp, #emphasis, #ensure_main_encoding, #ensure_utf_encoding, #eparse, #erev, #esteelblue, #etomato, #ewarn, #exit_program, #firebrick, #get_current_day, #get_current_month, #get_files_and_directories, #get_files_from, #get_german_name_for_this_weekday, #gold, #green, #grey, #hh_mm_ss, #hh_mm_ss_day_month_year, #home_dir?, #home_directory_of_user_x?, #infer_the_namespace, #internal_hash?, #is_a_directory?, #is_a_file?, #is_a_jpg_file?, #is_an_image_file?, #is_archive?, #is_audio_file?, #is_in_studium_dir?, #is_multimedia_file?, #is_on_roebe?, #is_on_windows?, #is_studium_available?, #is_symlink?, #is_this_a_ruby_file?, #is_video_file?, #iso_encoding?, #le, #left_colour, #lightblue, #lightgreen, #lightseagreen, #lightsteelblue, #lime, #limegreen, #localhost_to_data, #log_directory?, #main_encoding?, #mediumorchid, #mediumpurple, #mediumseagreen, #mediumslateblue, #mediumspringgreen, #mediumturquoise, #mkdir_p, #mv, #n_days_in_this_month, #n_pages_in_this_pdf_file?, #namespace?, #no_file_exists_at, #ogrey, #olive, #olivedrab, #open_in_browser, #opne, #opnesystem, #opnn, #orange, #orchid, #orev, #palegoldenrod, #palevioletred, #pink, #powderblue, #programs_dir?, #project_base_dir?, #random_html_colour, #rds, #read_file_in_iso_encoding, #read_file_via_the_default_encoding, #read_lines_via_iso_encoding, #readlines_with_main_encoding, #red, #register_sigint, #remove, #remove_directory, #remove_file, #rename_kde_konsole_tab, #replace_localhost_with_data, #report_pwd, #require_rescue, #reset_the_internal_hash, #return_all_directories_from_this_directory, #return_all_files_from_this_directory, #return_current_directory, #return_dd_mm_yyyy, #return_file_or_directory_of, #return_files_from_pwd, #return_last_part_of_the_current_directory, #return_utc, #rev, #right_arrow?, #right_colour, #roebe_log_directory?, #rosybrown, #royalblue, #ruby_base_directory?, #run_in_background, #run_rcfiles_then_run_ata_via_qdbus, #sandybrown, #sdir, #seagreen, #set_be_verbose, #set_xorg_buffer, #sfancy, #sfile, #show_help, #silent_redirection?, #simp, #simple_esystem, #skyblue, #slateblue, #slategray, #springgreen, #steelblue, #string_italic, #swarn, #symlink, #teal, #temp_dir?, #to_camelcase, #to_counted_hash, #tomato, #touch, #try_to_require_the_beautiful_url_gem, #try_to_require_the_html_template, #try_to_require_the_open_gem, #try_to_require_the_program_information_gem, #try_to_require_the_xorg_buffer, #use_colours?, #verbose_truth, #weekday?, #word_wrap, #write_what_into, #yellow

Methods included from Base::CommandlineArguments

#append_onto_the_commandline_arguments, #clear_commandline_arguments, #commandline_arguments?, #commandline_arguments_as_string?, #commandline_arguments_without_leading_hyphens?, #first_argument?, #first_argument_without_leading_hyphens?, #has_an_argument_been_passed?, #remove_hyphened_arguments_from_the_commandline_arguments, #return_commandline_arguments_with_leading_hyphens, #second_argument?, #set_commandline_arguments

Constructor Details

#initialize(i = ARGV, run_already = true) ⇒ SimpleBootScript

#

initialize

#


29
30
31
32
33
34
35
36
# File 'lib/roebe/classes/simple_boot_script.rb', line 29

def initialize(
    i           = ARGV,
    run_already = true
  )
  reset
  set_commandline_arguments(i)
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

Roebe::SimpleBootScript[]

#


350
351
352
# File 'lib/roebe/classes/simple_boot_script.rb', line 350

def self.[](i = ARGV)
  new(i)
end

Instance Method Details

#disable_caps_lock_keyObject

#

disable_caps_lock_key

#


77
78
79
80
# File 'lib/roebe/classes/simple_boot_script.rb', line 77

def disable_caps_lock_key
  e_counter 'Disabling the CAPS Lock key next:'
  esystem 'setxkbmap -option ctrl:nocaps', :do_colourize
end

#e_counter(i) ⇒ Object

#

e_counter

#


85
86
87
88
89
# File 'lib/roebe/classes/simple_boot_script.rb', line 85

def e_counter(i)
  @counter +=1
  e '('+sfancy(@counter.to_s)+') '+
    steelblue(i)
end

#ecmd(i) ⇒ Object

#

ecmd

#


224
225
226
# File 'lib/roebe/classes/simple_boot_script.rb', line 224

def ecmd(i)
  esystem i, :do_colourize
end

#fast_keyboardObject

#

fast_keyboard

#


61
62
63
64
# File 'lib/roebe/classes/simple_boot_script.rb', line 61

def fast_keyboard
  e_counter 'Setting the keyboard repeat rate next:'
  esystem 'xset r rate 200 30', :do_colourize
end
#
#


323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/roebe/classes/simple_boot_script.rb', line 323

def handle_non_xorg_related_boot_phase
  verbose_start_lighttpd                                   #  (1)
  verbose_load_german_keyboard                             #  (2)
  verbose_do_sync_the_hardware_clock_onto_the_local_clock  #  (3)
  verbose_start_the_ntp_daemon                             #  (4)
  verbose_start_alsa                                       #  (5)
  verbose_start_syslog_daemon                              #  (6)
  # verbose_start_crond # Not in use right now.
  verbose_start_cups                                       #  (7)
  verbose_start_haveged_daemon                             #  (8)
  verbose_start_udev                                       #  (9)
  verbose_start_the_ACPI_daemon                            # (10)
  verbose_start_messagebus                                 # (11)
  verbose_connect_to_the_internet_via_dhcpcd               # (12)
end
#
#


124
125
126
127
128
129
# File 'lib/roebe/classes/simple_boot_script.rb', line 124

def handle_xorg_related_boot_phase
  fast_keyboard         # (1)
  load_bluefish         # (2)
  disable_caps_lock_key # (3)
  start_konsole         # (4)
end

#load_bluefishObject

#

load_bluefish

#


53
54
55
56
# File 'lib/roebe/classes/simple_boot_script.rb', line 53

def load_bluefish
  e_counter 'Loading up the bluefish editor next:'
  esystem 'bluefish &', :do_colourize
end
#

menu (menu tag)

#


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
# File 'lib/roebe/classes/simple_boot_script.rb', line 134

def menu(
    i = commandline_arguments?
  )
  if i.is_a? Array
    if i.empty?
      handle_non_xorg_related_boot_phase
    else
      i.each {|entry| menu(entry) }
    end
  else
    case i # case tag
    # ===================================================================== #
    # === simpleboot --default
    # ===================================================================== #
    when /^-?-?default/,'',nil
      handle_non_xorg_related_boot_phase
    # ===================================================================== #
    # === simpleboot --xorg
    # ===================================================================== #
    when /^-?-?xorg/i,
         /^-?-?GUI/i
      handle_xorg_related_boot_phase
    end
  end
end

#resetObject

#

reset (reset tag)

#


41
42
43
44
45
46
47
48
# File 'lib/roebe/classes/simple_boot_script.rb', line 41

def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @counter
  # ======================================================================= #
  @counter = 0
end

#runObject

#

run (run tag)

#


316
317
318
# File 'lib/roebe/classes/simple_boot_script.rb', line 316

def run
  menu
end

#start_konsoleObject

#

start_konsole (konsole tag)

#


69
70
71
72
# File 'lib/roebe/classes/simple_boot_script.rb', line 69

def start_konsole
  e_counter 'Starting KDE konsole next:'
  esystem 'konsole --tabs-from-file /home/x/programming/ruby/src/roebe/lib/roebe/www/kde/konsole_multiple_tabs &', :do_colourize
end

#stop_syslogdObject Also known as: syslogd_stop

#

stop_syslogd

#


270
271
272
# File 'lib/roebe/classes/simple_boot_script.rb', line 270

def stop_syslogd
  esystem 'killall syslogd'
end

#verbose_connect_to_the_internet_via_dhcpcdObject

#

verbose_connect_to_the_internet_via_dhcpcd

#


94
95
96
97
# File 'lib/roebe/classes/simple_boot_script.rb', line 94

def verbose_connect_to_the_internet_via_dhcpcd
  e_counter 'Connect to the internet:'
  esystem 'ruby_dhcpcd eth0', :do_colourize
end

#verbose_do_sync_the_hardware_clock_onto_the_local_clockObject

#

verbose_do_sync_the_hardware_clock_onto_the_local_clock

This method will sync the hardware clock onto the local clock.

#


104
105
106
107
# File 'lib/roebe/classes/simple_boot_script.rb', line 104

def verbose_do_sync_the_hardware_clock_onto_the_local_clock
  e_counter 'Syncing the hardware clock onto the local clock:'
  esystem 'hwclock -s', :do_colourize
end

#verbose_load_german_keyboardObject

#

verbose_load_german_keyboard

Load the proper german keyboard (“keymap”) here.

Other users may prefer the US keyboard variant instead.

#


116
117
118
119
# File 'lib/roebe/classes/simple_boot_script.rb', line 116

def verbose_load_german_keyboard
  e_counter 'German keyboard:'
  esystem 'loadkeys --unicode de', :do_colourize
end

#verbose_start_alsaObject Also known as: verbose_alsa

#

verbose_start_alsa

This method will load the mixer settings for ALSA, the Advanced Linux Sound Architecture.

#


298
299
300
301
302
# File 'lib/roebe/classes/simple_boot_script.rb', line 298

def verbose_start_alsa
  cmd = '/usr/sbin/alsactl restore'
  e_counter "Loading the #{steelblue('ALSA mixer settings')}:  #{cmd}"
  esystem cmd, :do_colourize
end

#verbose_start_crondObject

#

verbose_start_crond (crond tag)

#


277
278
279
280
281
# File 'lib/roebe/classes/simple_boot_script.rb', line 277

def verbose_start_crond
  cmd = '/usr/sbin/crond $CROND_OPTS'
  e_counter "Starting #{steelblue('crond')}:  #{cmd}"
  esystem cmd, :do_colourize
end

#verbose_start_cupsObject

#

verbose_start_cups (cups tag)

#


286
287
288
289
290
# File 'lib/roebe/classes/simple_boot_script.rb', line 286

def verbose_start_cups
  cmd = '/usr/sbin/cupsd'
  e_counter "Loading the #{steelblue('ALSA mixer settings')}:  #{cmd}"
  esystem cmd, :do_colourize
end

#verbose_start_haveged_daemonObject

#

verbose_start_haveged_daemon

The haveged project is an attempt to provide an easy-to-use, unpredictable random number generator based upon an adaptation of the HAVEGE algorithm. Haveged was created to remedy low-entropy conditions in the Linux random device that can occur under some workloads, especially on headless servers.

#


259
260
261
262
263
264
265
# File 'lib/roebe/classes/simple_boot_script.rb', line 259

def verbose_start_haveged_daemon
  haveged_pidfile = '/var/run/haveged.pid'
  haveged_options = "-w 1024 -v 1 -p #{haveged_pidfile}"
  cmd = '/sbin/haveged '+haveged_options
  e_counter "Starting the #{steelblue('haveged entropy daemon')}:  #{cmd}"
  ecmd(cmd)
end

#verbose_start_lighttpdObject

#

verbose_start_lighttpd (slighty tag)

#


342
343
344
345
# File 'lib/roebe/classes/simple_boot_script.rb', line 342

def verbose_start_lighttpd
  e '(1) Starting lighty next:'
  Roebe.start_lighttpd
end

#verbose_start_messagebusObject

#

verbose_start_messagebus

#


231
232
233
234
235
236
237
238
# File 'lib/roebe/classes/simple_boot_script.rb', line 231

def verbose_start_messagebus
  _pidfile = '/var/run/dbus/dbus.pid' # This pid-file is currently not in use.
  cmd1 = '/usr/bin/dbus-uuidgen --ensure'
  cmd2 = '/usr/bin/dbus-daemon --system 1'
  e_counter "Starting the #{steelblue('system message bus')}:  #{cmd1}, then #{cmd2}"
  ecmd(cmd1)
  ecmd(cmd2)
end

#verbose_start_syslog_daemonObject

#

verbose_start_syslog_daemon

#


163
164
165
166
167
# File 'lib/roebe/classes/simple_boot_script.rb', line 163

def verbose_start_syslog_daemon
  cmd = '/usr/sbin/syslogd $SYSLOGD_OPTS'
  e_counter "Starting the #{steelblue('syslogd daemon')}:  #{cmd}"
  esystem cmd, :do_colourize
end

#verbose_start_the_ACPI_daemonObject

#

verbose_start_the_ACPI_daemon

#


243
244
245
246
247
# File 'lib/roebe/classes/simple_boot_script.rb', line 243

def verbose_start_the_ACPI_daemon
  cmd = '/usr/sbin/acpid'
  e_counter "Starting the #{steelblue('ACPI daemon')}:  #{cmd}"
  ecmd(cmd)
end

#verbose_start_the_ntp_daemonObject

#

verbose_start_the_ntp_daemon

#


307
308
309
310
311
# File 'lib/roebe/classes/simple_boot_script.rb', line 307

def verbose_start_the_ntp_daemon
  cmd = '/usr/sbin/ntpd -g -u ntp:ntp'
  e_counter "Starting the #{steelblue('NTP daemon')}:  #{cmd}"
  esystem cmd, :do_colourize
end

#verbose_start_udevObject

#

verbose_start_udev (udev tag)

The key-binary to control udev is “udevadm”.

Reloadingthe udev rules can be done via:

udevadm control --reload
#


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
# File 'lib/roebe/classes/simple_boot_script.rb', line 179

def verbose_start_udev
  e_counter "Starting #{steelblue('udev')}:"
  # ======================================================================= #
  # Starting udev requires several steps one after the other:
  # ======================================================================= #
  mkdir('/dev/pts')
  cmd = 'mount -n -o mode=0620,gid=5 -t devpts devpts /dev/pts'
  ecmd(cmd)
  # ======================================================================= #
  # Next, mount /dev/shm:
  # ======================================================================= #
  mkdir('/dev/shm')
  mkdir('/dev/null')
  cmd = 'mount /dev/shm'
  ecmd(cmd)
  # ======================================================================= #
  # Next, mount tmpfs on /dev:
  # ======================================================================= #
  # or use:
  #   mount -n -o mode=0755 -t tmpfs -o size=8M tmpfs /dev
  # ======================================================================= #
  cmd = 'mount -n -t devtmpfs -o size=8M devtmpfs /dev'
  ecmd(cmd)
  e 'Creating static nodes in /dev next.'
  cmd = 'kmod static-nodes -f tmpfiles --output /run/static-nodes'
  ecmd(cmd)
  e 'Todo: missing mknod -m calls here.'
  cmd = '/sbin/udevd --daemon'
  ecmd(cmd)
  e "Triggering udev events:  /sbin/udevadm trigger --action=add"
  # ======================================================================= #
  # Call udevtrigger and udevsettle to do the device configuration:
  # ======================================================================= #
  cmd = '/sbin/udevadm trigger --type=subsystems --action=add'
  ecmd(cmd)
  cmd = '/sbin/udevadm trigger --type=devices --action=add'
  ecmd(cmd)
  e "Updating the hardware database index:  /sbin/udevadm hwdb --update"
  cmd = '/sbin/udevadm hwdb --update'
  ecmd(cmd)
end