OSDN Git Service

dace997bcf4143b006ff32fcd31b7c899d632d22
[metasearch/grid-chef-repo.git] / cookbooks / platform_utils / recipes / grub_default.rb
1 #
2 # Cookbook Name:: platform_utils
3 # Recipe:: grub_default
4 #
5 # Copyright 2018, whitestar
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 unless File.exist?('/boot/grub/grub.cfg')
21   Chef::Log.warn('recipe[platform_utils::grub_default] GRUB 2 is not installed yet.')
22   return
23 end
24
25 execute 'update-grub2' do
26   user 'root'
27   command 'update-grub2'
28   action :nothing
29   only_if 'update-grub2 --version'
30 end
31
32 dir = '/etc/default/grub.d'
33 resources(directory: dir) rescue directory dir do
34   owner 'root'
35   group 'root'
36   mode '0755'
37 end
38
39 template '/etc/default/grub.d/override.cfg' do
40   source  'etc/default/grub.d/override.cfg'
41   owner 'root'
42   group 'root'
43   mode '0644'
44   notifies :run, 'execute[update-grub2]'
45 end