Class: Roebe::LiloConfigGenerator
- Inherits:
-
Base
show all
- Defined in:
- lib/roebe/classes/lilo_config_generator.rb
Overview
Roebe::LiloConfigGenerator
Constant Summary
collapse
- HDD_ENTRY =
'/dev/sda'
- N_SECONDS_TIMEOUT =
'600'
Constants inherited
from Base
Base::COLOURS, Base::HOME_DIRECTORY_OF_USER_X, Base::N, Base::NAMESPACE
Class Method Summary
collapse
-
.[](i = '') ⇒ Object
# === Roebe::LiloConfigGenerator[] ========================================================================= #.
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, #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, #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
#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?
Constructor Details
#initialize(i = ARGV, run_already = true) ⇒ LiloConfigGenerator
45
46
47
48
49
50
51
52
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 45
def initialize(
i = ARGV,
run_already = true
)
reset
set_commandline_arguments(i)
run if run_already
end
|
Class Method Details
.[](i = '') ⇒ Object
#
Roebe::LiloConfigGenerator[]
#
395
396
397
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 395
def self.[](i = '')
new(i)
end
|
Instance Method Details
#add(i = N) ⇒ Object
131
132
133
134
135
136
137
138
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 131
def add(i = N)
i = i.dup if i.frozen?
i << N unless i.end_with? N
if i.start_with? '#'
i.prepend(' ') end
@_ << i
end
|
#add_boot_area ⇒ Object
#
add_boot_area
Instructs LILO to be installed on the first hard disk of the first IDE controller or sd-device.
This is equivalent to the MBR, so no trailing numbers here.
When LILO is installed into the MBR, it will control the boot-up process.
#
151
152
153
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 151
def add_boot_area
add "boot=#{HDD_ENTRY}"
end
|
#add_compact ⇒ Object
#
add_compact
Note that the “compact” setting makes LILO read the hard drive faster. Normally you want this, but some older systems may hang. Remove it if yours is one of these.
#
232
233
234
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 232
def add_compact
add 'compact'
end
|
#add_default_bitmap ⇒ Object
310
311
312
313
314
315
316
317
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 310
def add_default_bitmap
_ = '/boot/slack.bmp'
if File.exist? _
add "bitmap = #{_}"
else
opnn; no_file_exists_at(_)
end
end
|
111
112
113
114
115
116
117
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 111
def
cliner
add '# Menu colors (foreground, background, shadow, highlighted'
add '# foreground, highlighted background, highlighted shadow):'
cliner
add 'bmp-colors = 255,0,255,0,255,0'
end
|
#add_map_file ⇒ Object
221
222
223
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 221
def add_map_file
add 'map=/boot/map'
end
|
#add_option_table ⇒ Object
104
105
106
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 104
def add_option_table
add 'bmp-table = 60,6,1,16'
end
|
#add_prompt ⇒ Object
207
208
209
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 207
def add_prompt
add 'prompt'
end
|
#add_this_bootable_partition_subsection(use_this_kernel = '/boot/vmlinuz-huge-4.4.14', use_this_as_label = 'Linux_1') ⇒ Object
#
add_this_bootable_partition_subsection
#
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
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 239
def add_this_bootable_partition_subsection(
use_this_kernel = '/boot/vmlinuz-huge-4.4.14',
use_this_as_label = 'Linux_1'
)
if use_this_as_label.frozen?
use_this_as_label = use_this_as_label.dup
end
target_file = use_this_kernel.dup
if File.exist? target_file
cliner
add '# Linux bootable partition config:'
cliner
add 'image = '+target_file
add ' root = '+@use_this_as_the_main_device
if use_this_kernel.include? '-huge-'
use_this_as_label << '-huge'
elsif use_this_kernel.include? '-generic-'
use_this_as_label << '-generic'
end
add ' label = '+use_this_as_label
add ' read-only'
n
else
opnn; no_file_exists_at(target_file)
end
end
|
#add_timeout ⇒ Object
#
add_timeout
timout will set the amount of time that LILO waits for user input, before proceeding with booting the default line entry. 50 is the default and means 5 seconds (divide by 10).
#
190
191
192
193
194
195
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 190
def add_timeout
cliner
add '# This is given in tenths of a second, so 600 for every minute:'
cliner
add "timeout = #{N_SECONDS_TIMEOUT}"
end
|
158
159
160
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 158
def cliner
add '# '+('='*74)+' #'
end
|
#consider_running_lilo_at_once ⇒ Object
#
consider_running_lilo_at_once
This method will run “lilo” at once, if we are on a roebe-system.
#
369
370
371
372
373
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 369
def consider_running_lilo_at_once
if is_on_roebe?
esystem 'lilo'
end
end
|
#determine_the_available_boot_devices_automatically ⇒ Object
#
determine_the_available_boot_devices_automatically
This method can be used to
#
380
381
382
383
384
385
386
387
388
389
390
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 380
def determine_the_available_boot_devices_automatically
possible_matches = Dir['/boot/vmlinuz-*'].reject {|entry| File.symlink? entry }
possible_matches.each {|this_vmlinuz_file|
version = this_vmlinuz_file.scan(/(\d{0,2}\.\d{0,2}\.\d{0,2})/).flatten.compact
version = version.first if version.is_a? Array
add_this_bootable_partition_subsection(
this_vmlinuz_file,
"linux-#{version}"
)
}
end
|
#main_string? ⇒ Boolean
200
201
202
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 200
def main_string?
@_
end
|
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 277
def (i)
if i.is_a? Array
i.each {|entry| (entry) }
else
case i when /^-?-?help$/i,
/^-?-?show(_|-)?help$/i
show_help
exit
when /^-?-?entry=(.+)$/i
set_use_this_entry($1.to_s.dup)
end
end
end
|
#
n
Add a newline to the config file.
#
124
125
126
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 124
def n
add N
end
|
#override_dangerous_defaults ⇒ Object
#
override_dangerous_defaults
#
175
176
177
178
179
180
181
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 175
def override_dangerous_defaults
cliner
add '# Override dangerous defaults that rewrite the partition table:'
cliner
add 'change-rules'
add ' reset'
end
|
#parse_commandline_arguments ⇒ Object
#
parse_commandline_arguments
#
93
94
95
96
97
98
99
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 93
def parse_commandline_arguments
if @commandline_arguments.any? {|entry| entry.start_with? '--' }
selection = @commandline_arguments.select {|entry| entry.start_with? '--' }
(selection)
@commandline_arguments.reject! {|entry| entry.start_with? '--' }
end
end
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 57
def reset
super()
infer_the_namespace
@_ = ''.dup @use_this_as_the_main_device = '/dev/sda1'
end
|
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
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 335
def run
opne 'This class will next generate a (default) lilo config file.'
add_boot_area
n
add_map_file
n
add_default_bitmap
n
n
add_option_table
n
add_compact
n
add_prompt
n
add_timeout
n
override_dangerous_defaults
n
use_normal_vga_console
n
determine_the_available_boot_devices_automatically
e
show_main_string
save_into_lilo_conf_file
consider_running_lilo_at_once
end
|
#save_into_lilo_conf_file ⇒ Object
#
save_into_lilo_conf_file
Note that by default we will generate into the current working directory.
#
325
326
327
328
329
330
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 325
def save_into_lilo_conf_file
what = main_string?
into = '/etc/lilo.conf'
opne 'Storing the above into the file `'+sfile(into)+'`.'
write_what_into(what, into)
end
|
#set_commandline_arguments(i = '') ⇒ Object
#
set_commandline_arguments
#
84
85
86
87
88
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 84
def set_commandline_arguments(i = '')
i = [i].flatten.compact
@commandline_arguments = i
parse_commandline_arguments
end
|
#set_use_this_as_the_main_device(i) ⇒ Object
Also known as:
set_use_this_entry
#
set_use_this_as_the_main_device
Specify using another main device entry here.
#
77
78
79
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 77
def set_use_this_as_the_main_device(i)
@use_this_as_the_main_device = i
end
|
#show_help ⇒ Object
301
302
303
304
305
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 301
def show_help
e
e " liloconfig --entry=/dev/sda2 # specify to use another main entry"
e
end
|
#show_main_string ⇒ Object
Also known as:
report
214
215
216
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 214
def show_main_string
e @_
end
|
#use_normal_vga_console ⇒ Object
#
use_normal_vga_console
#
165
166
167
168
169
170
|
# File 'lib/roebe/classes/lilo_config_generator.rb', line 165
def use_normal_vga_console
cliner
add '# Normal VGA console'
cliner
add 'vga = normal'
end
|