文件操作 - gentoo.rb
返回文件管理
返回主菜单
删除本文件
文件: /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/service/gentoo.rb
编辑文件内容
# frozen_string_literal: true # Manage gentoo services. Start/stop is the same as InitSvc, but enable/disable # is special. Puppet::Type.type(:service).provide :gentoo, :parent => :init do desc <<-EOT Gentoo's form of `init`-style service management. Uses `rc-update` for service enabling and disabling. EOT commands :update => "/sbin/rc-update" confine 'os.name' => :gentoo def disable output = update :del, @resource[:name], :default rescue Puppet::ExecutionFailure => e raise Puppet::Error, "Could not disable #{name}: #{output}", e.backtrace end def enabled? begin output = update :show rescue Puppet::ExecutionFailure return :false end line = output.split(/\n/).find { |l| l.include?(@resource[:name]) } return :false unless line # If it's enabled then it will print output showing service | runlevel if output =~ /^\s*#{@resource[:name]}\s*\|\s*(boot|default)/ :true else :false end end def enable output = update :add, @resource[:name], :default rescue Puppet::ExecutionFailure => e raise Puppet::Error, "Could not enable #{name}: #{output}", e.backtrace end end
修改文件时间
将文件时间修改为当前时间的前一年
删除文件