init.pp
1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class ps1 (
$color = 'red'
) {
$color_code = $color ? {
'red' => '1',
'green' => '2',
'yellow' => '3',
default => '1'
}
$force_color_prompt_cmd = "/bin/sed -i -re '/force_color_prompt=yes/ s/^#//'"
$force_color_prompt_condition = '/bin/grep "#force_color_prompt"'
$ps1_color_cmd = "/bin/sed -i -re 's/01;3[1-3]m/01;3${color_code}m/'"
$ps1_color_condition = "/bin/grep '01;3${color_code}m'"
$skel_path = '/etc/skel/.bashrc'
$root_path = '/root/.bashrc'
# uncomment force_color_prompt in skel
exec { "$force_color_prompt_cmd $skel_path":
onlyif => "$force_color_prompt_condition $skel_path"
}
# uncomment force_color_prompt in root
exec { "$force_color_prompt_cmd $root_path":
onlyif => "$force_color_prompt_condition $root_path"
}
# change prompt color in skel
exec { "$ps1_color_cmd $skel_path":
unless => "$ps1_color_condition $skel_path",
}
# change prompt color in root
exec { "$ps1_color_cmd $root_path":
unless => "$ps1_color_condition $root_path",
}
}