class OpenWrt < Oxidized::Model prompt /^[^#]+#/ comment '#' cmd 'cat /etc/banner' do |cfg| comment "#### Info: /etc/banner #####\n#{cfg}" end cmd 'cat /proc/cpuinfo' do |cfg| comment "#### Info: /proc/cpuinfo #####\n#{cfg}" end cmd 'cat /etc/openwrt_release' do |cfg| comment "#### Info: /etc/openwrt_release #####\n#{cfg}" end cmd 'sysupgrade -l' do |cfg| @sysupgradefiles = cfg comment "#### Info: sysupgrade -l #####\n#{cfg}" end cmd 'cat /proc/mtd' do |cfg| @mtdpartitions = cfg comment "#### Info: /proc/mtd #####\n#{cfg}" end post do cfg = [] binary_files = vars(:openwrt_binary_files) || %w[/etc/dropbear/dropbear_rsa_host_key] non_sensitive_files = vars(:openwrt_non_sensitive_files) || %w[rpcd uhttpd] partitions_to_backup = vars(:openwrt_partitions_to_backup) || %w[art devinfo u_env config caldata] @sysupgradefiles.lines.each do |sysupgradefile| sysupgradefile = sysupgradefile.strip if sysupgradefile.start_with?('/etc/config/') unless sysupgradefile.end_with?('-opkg') filename = sysupgradefile.split('/')[-1] cfg << comment("#### File: #{sysupgradefile} #####") uciexport = cmd("uci export #{filename}") Oxidized.logger.debug "Exporting uci config - #{filename}" if vars(:remove_secret) && !(non_sensitive_files.include? filename) Oxidized.logger.debug "Scrubbing uci config - #{filename}" uciexport.gsub!(/^(\s+option\s+(password|key)\s+')[^']+'/, '\\1