|
61 | 61 | $group = $name |
62 | 62 | } |
63 | 63 |
|
| 64 | + if $set_sh { |
| 65 | + if !defined(User[$name]) { |
| 66 | + user { "ohmyzsh::user ${name}": |
| 67 | + ensure => present, |
| 68 | + name => $name, |
| 69 | + managehome => true, |
| 70 | + shell => lookup('ohmyzsh::zsh_shell_path'), |
| 71 | + require => Package['zsh'], |
| 72 | + } |
| 73 | + } else { |
| 74 | + User <| title == $name |> { |
| 75 | + shell => lookup('ohmyzsh::zsh_shell_path') |
| 76 | + } |
| 77 | + |
| 78 | + Package['zsh'] -> User <| title == $name |> |
| 79 | + } |
| 80 | + } |
| 81 | + |
64 | 82 | vcsrepo { "${home}/.oh-my-zsh": |
65 | 83 | ensure => $ensure, |
66 | 84 | provider => git, |
|
69 | 87 | user => $name, |
70 | 88 | require => Package['git'], |
71 | 89 | } |
72 | | - |
73 | | - if $update_zshrc == sync { |
| 90 | + -> if $update_zshrc == sync { |
74 | 91 | if $backup_zshrc { |
75 | 92 | exec { "backup .zshrc ${name}": |
76 | 93 | command => "cp ${home}/.zshrc ${home}/.zshrc.bak.${date_command}", |
77 | 94 | path => ['/bin', '/usr/bin'], |
| 95 | + onlyif => "test -f ${home}/.zshrc", |
78 | 96 | user => $name, |
79 | 97 | before => [ |
80 | 98 | File_Line["ohmyzsh::auto_update_frequency - ${name}"], |
|
100 | 118 | path => ['/bin', '/usr/bin'], |
101 | 119 | onlyif => "getent passwd ${name} | cut -d : -f 6 | xargs test -e", |
102 | 120 | user => $name, |
103 | | - require => Vcsrepo["${home}/.oh-my-zsh"], |
104 | | - before => [ |
105 | | - File_Line["ohmyzsh::auto_update_frequency - ${name}"], |
106 | | - ], |
107 | 121 | } |
108 | 122 | } elsif $update_zshrc == always { |
109 | 123 | if $backup_zshrc { |
110 | 124 | exec { "backup .zshrc ${name}": |
111 | | - command => "cp ${home}/.zshrc ${home}/.zshrc.bak.${date_command}", |
112 | | - path => ['/bin', '/usr/bin'], |
113 | | - user => $name, |
114 | | - before => [ |
115 | | - File_Line["ohmyzsh::auto_update_frequency - ${name}"], |
116 | | - ], |
117 | | - require => Vcsrepo["${home}/.oh-my-zsh"], |
| 125 | + command => "cp ${home}/.zshrc ${home}/.zshrc.bak.${date_command}", |
| 126 | + path => ['/bin', '/usr/bin'], |
| 127 | + onlyif => "test -f ${home}/.zshrc", |
| 128 | + user => $name, |
118 | 129 | } |
119 | 130 | } |
120 | 131 | -> exec { "ohmyzsh::cp .zshrc ${name}": |
121 | 132 | command => "cp ${home}/.oh-my-zsh/templates/zshrc.zsh-template ${home}/.zshrc", |
122 | 133 | path => ['/bin', '/usr/bin'], |
123 | 134 | user => $name, |
124 | | - before => [ |
125 | | - File_Line["ohmyzsh::auto_update_frequency - ${name}"], |
126 | | - ], |
127 | | - require => Vcsrepo["${home}/.oh-my-zsh"], |
128 | | - } |
129 | | - } |
130 | | - |
131 | | - if $set_sh { |
132 | | - if !defined(User[$name]) { |
133 | | - user { "ohmyzsh::user ${name}": |
134 | | - ensure => present, |
135 | | - name => $name, |
136 | | - managehome => true, |
137 | | - shell => lookup('ohmyzsh::zsh_shell_path'), |
138 | | - require => Package['zsh'], |
139 | | - } |
140 | | - } else { |
141 | | - User <| title == $name |> { |
142 | | - shell => lookup('ohmyzsh::zsh_shell_path') |
143 | | - } |
144 | | - |
145 | | - Package['zsh'] -> User <| title == $name |> |
146 | 135 | } |
147 | 136 | } |
148 | | - |
149 | | - file_line { "ohmyzsh::auto_update_frequency - ${name}": |
| 137 | + -> file_line { "ohmyzsh::auto_update_frequency - ${name}": |
150 | 138 | path => "${home}/.zshrc", |
151 | 139 | line => "zstyle ':omz:update' frequency ${auto_update_frequency}", |
152 | 140 | match => '.*zstyle\ \':omz:update\'\ frequency .*', |
153 | 141 | } |
154 | | - if $auto_update_mode == disabled { |
| 142 | + -> if $auto_update_mode == disabled { |
155 | 143 | file_line { "enable ohmyzsh::auto_update_mode disabled - ${name}": |
156 | | - path => "${home}/.zshrc", |
157 | | - line => "zstyle ':omz:update' mode disabled", |
158 | | - match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*', |
159 | | - require => File_Line["ohmyzsh::auto_update_frequency - ${name}"], |
| 144 | + path => "${home}/.zshrc", |
| 145 | + line => "zstyle ':omz:update' mode disabled", |
| 146 | + match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*', |
160 | 147 | } |
161 | 148 | file_line { "disable ohmyzsh::auto_update_mode auto - ${name}": |
162 | | - path => "${home}/.zshrc", |
163 | | - line => "# zstyle ':omz:update' mode auto", |
164 | | - match => '.*zstyle\ \':omz:update\'\ mode\ auto.*', |
165 | | - require => File_Line["ohmyzsh::auto_update_frequency - ${name}"], |
| 149 | + path => "${home}/.zshrc", |
| 150 | + line => "# zstyle ':omz:update' mode auto", |
| 151 | + match => '.*zstyle\ \':omz:update\'\ mode\ auto.*', |
166 | 152 | } |
167 | 153 | file_line { "disable ohmyzsh::auto_update_mode reminder - ${name}": |
168 | | - path => "${home}/.zshrc", |
169 | | - line => "# zstyle ':omz:update' mode reminder", |
170 | | - match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*', |
171 | | - require => File_Line["ohmyzsh::auto_update_frequency - ${name}"], |
| 154 | + path => "${home}/.zshrc", |
| 155 | + line => "# zstyle ':omz:update' mode reminder", |
| 156 | + match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*', |
172 | 157 | } |
173 | 158 | } elsif $auto_update_mode == auto { |
174 | 159 | file_line { "enable ohmyzsh::auto_update_mode auto - ${name}": |
175 | | - path => "${home}/.zshrc", |
176 | | - line => "zstyle ':omz:update' mode auto", |
177 | | - match => '.*zstyle\ \':omz:update\'\ mode\ auto.*', |
178 | | - require => File_Line["ohmyzsh::auto_update_frequency - ${name}"], |
| 160 | + path => "${home}/.zshrc", |
| 161 | + line => "zstyle ':omz:update' mode auto", |
| 162 | + match => '.*zstyle\ \':omz:update\'\ mode\ auto.*', |
179 | 163 | } |
180 | 164 | file_line { "disable ohmyzsh::auto_update_mode disabled - ${name}": |
181 | | - path => "${home}/.zshrc", |
182 | | - line => "# zstyle ':omz:update' mode disabled", |
183 | | - match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*', |
184 | | - require => File_Line["ohmyzsh::auto_update_frequency - ${name}"], |
| 165 | + path => "${home}/.zshrc", |
| 166 | + line => "# zstyle ':omz:update' mode disabled", |
| 167 | + match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*', |
185 | 168 | } |
186 | 169 | file_line { "disable ohmyzsh::auto_update_mode reminder - ${name}": |
187 | | - path => "${home}/.zshrc", |
188 | | - line => "# zstyle ':omz:update' mode reminder", |
189 | | - match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*', |
190 | | - require => File_Line["ohmyzsh::auto_update_frequency - ${name}"], |
| 170 | + path => "${home}/.zshrc", |
| 171 | + line => "# zstyle ':omz:update' mode reminder", |
| 172 | + match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*', |
191 | 173 | } |
192 | 174 | } elsif $auto_update_mode == reminder { |
193 | 175 | file_line { "enable ohmyzsh::auto_update_mode reminder - ${name}": |
194 | | - path => "${home}/.zshrc", |
195 | | - line => "zstyle ':omz:update' mode reminder", |
196 | | - match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*', |
197 | | - require => File_Line["ohmyzsh::auto_update_frequency - ${name}"], |
| 176 | + path => "${home}/.zshrc", |
| 177 | + line => "zstyle ':omz:update' mode reminder", |
| 178 | + match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*', |
198 | 179 | } |
199 | 180 | file_line { "disable ohmyzsh::auto_update_mode auto - ${name}": |
200 | | - path => "${home}/.zshrc", |
201 | | - line => "# zstyle ':omz:update' mode auto", |
202 | | - match => '.*zstyle\ \':omz:update\'\ mode\ auto.*', |
203 | | - require => File_Line["ohmyzsh::auto_update_frequency - ${name}"], |
| 181 | + path => "${home}/.zshrc", |
| 182 | + line => "# zstyle ':omz:update' mode auto", |
| 183 | + match => '.*zstyle\ \':omz:update\'\ mode\ auto.*', |
204 | 184 | } |
205 | 185 | file_line { "disable ohmyzsh::auto_update_mode disabled - ${name}": |
206 | | - path => "${home}/.zshrc", |
207 | | - line => "# zstyle ':omz:update' mode disabled", |
208 | | - match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*', |
209 | | - require => File_Line["ohmyzsh::auto_update_frequency - ${name}"], |
| 186 | + path => "${home}/.zshrc", |
| 187 | + line => "# zstyle ':omz:update' mode disabled", |
| 188 | + match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*', |
210 | 189 | } |
211 | 190 | } |
212 | | - |
213 | 191 | # Fix permissions on '~/.oh-my-zsh/cache/completions' |
214 | | - file { "${home}/.oh-my-zsh/cache/completions": |
| 192 | + -> file { "${home}/.oh-my-zsh/cache/completions": |
215 | 193 | ensure => directory, |
216 | 194 | replace => 'no', |
217 | 195 | owner => $name, |
|
0 commit comments