Module: Linebook::Os::Linux
- Included in:
- Ubuntu
- Defined in:
- lib/linebook/os/linux.rb,
lib/linebook/os/linux/utilities.rb
Overview
Defines Linux-compliant functionality, based on the Linux Standard Base Core Specification 4.1 . See the online documentation for:
Posix does not specify commands for user management, but Linux does. Now that users are overtly in the mix, see How to Switch Users for picking a su policy.
Defined Under Namespace
Modules: Utilities
Instance Method Summary collapse
-
#_login(*args, &block) ⇒ Object
:nodoc:.
- #capture_script(options = {}) ⇒ Object
- #guess_target_name(source_name) ⇒ Object
-
#login(user = 'root', options = {}) ⇒ Object
Logs in as the specified user for the duration of a block (the current ENV and pwd are reset as during a normal login).
Methods included from Utilities
#_group?, #_groupadd, #_groupdel, #_groupmod, #_groups, #_gzip, #_hostname, #_install, #_md5sum, #_mktemp, #_su, #_tar, #_user?, #_useradd, #_userdel, #_usermod, #group?, #groupadd, #groupdel, #groupmod, #groups, #gzip, #hostname, #install, #md5sum, #mktemp, #su, #tar, #user?, #useradd, #userdel, #usermod
Methods included from Posix
#_append, #_break_, #_check_status, #_check_status_function, #_comment, #_continue_, #_elif_, #_else_, #_execute, #_exit_, #_from, #_heredoc, #_if_, #_redirect, #_return_, #_section, #_to, #_unless_, #_until_, #_variable, #_while_, #append, #break_, #check_status, #check_status_function, #command_str, #comment, #continue_, #elif_, #else_, #execute, #exit_, #from, #function, #function?, #functions, #heredoc, #if_, #option?, #option_quote, #options_str, #program_name, #quote, #quoted?, #redirect, #return_, #section, #signature, #to, #trailer, #unless_, #until_, #var, #variable, #while_
Methods included from Posix::Utilities
#_basename, #_cat, #_cd, #_chgrp, #_chmod, #_chown, #_cmp, #_comm, #_cp, #_cut, #_date, #_directory?, #_dirname, #_echo, #_executable?, #_exists?, #_expand, #_export, #_file?, #_fold, #_grep, #_has_content?, #_head, #_id, #_link?, #_ln, #_ls, #_mkdir, #_mv, #_paste, #_pathchk, #_pwd, #_read, #_readable?, #_rm, #_rmdir, #_sed, #_set, #_sort, #_split, #_tail, #_touch, #_tr, #_tsort, #_uname, #_unexpand, #_uniq, #_unset, #_wc, #_writable?, #basename, #cat, #cd, #chgrp, #chmod, #chown, #cmp, #comm, #cp, #cut, #date, #directory?, #dirname, #echo, #executable?, #exists?, #expand, #export, #file?, #fold, #grep, #has_content?, #head, #id, #link?, #ln, #ls, #mkdir, #mv, #paste, #pathchk, #pwd, #read, #readable?, #rm, #rmdir, #sed, #set, #sort, #split, #tail, #touch, #tr, #tsort, #uname, #unexpand, #uniq, #unset, #wc, #writable?
Instance Method Details
#_login(*args, &block) ⇒ Object
:nodoc:
63 64 65 66 67 |
# File 'lib/linebook/os/linux.rb', line 63 def _login(*args, &block) # :nodoc: str = capture_str { login(*args, &block) } str.strip! str end |
#capture_script(options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/linebook/os/linux.rb', line 30 def capture_script(={}) unless .kind_of?(Hash) = {:target_name => guess_target_name()} end target_name = [:target_name] || guess_target_name('script') path = capture_path(target_name, [:mode] || 0770) { yield } owner, group = [:owner], [:group] if owner || group callback 'before' do chown owner, group, path end end path end |
#guess_target_name(source_name) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/linebook/os/linux.rb', line 23 def guess_target_name(source_name) target_dir = File.dirname(target_name) name = File.basename(source_name) _package_.next_target_name(target_dir == '.' ? name : File.join(target_dir, name)) end |
#login(user = 'root', options = {}) ⇒ Object
Logs in as the specified user for the duration of a block (the current ENV and pwd are reset as during a normal login).
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/linebook/os/linux.rb', line 50 def login(user='root', ={}) current = functions begin @functions = nil path = capture_script() { yield } execute 'su', user, path, :l => true ensure @functions = current end chain_proxy end |