]>
Commit | Line | Data |
---|---|---|
1 | class profile::xmr_stak ( | |
2 | String $mining_pool, | |
3 | String $wallet, | |
4 | Optional[String] $cpulimit = "50", | |
5 | Optional[String] $password = "x", | |
6 | ) { | |
7 | unless empty($mining_pool) or $cpulimit == "0" { | |
8 | ensure_resource('exec', 'systemctl daemon-reload', { | |
9 | command => '/usr/bin/systemctl daemon-reload', | |
10 | refreshonly => true | |
11 | }) | |
12 | ||
13 | ensure_packages(["cpulimit"]) | |
14 | aur::package { "xmr-stak_cpu": | |
15 | ensure => "absent" | |
16 | } -> | |
17 | aur::package { "xmr-stak": } | |
18 | ~> | |
19 | exec { "remove cpu.txt": | |
20 | command => "/usr/bin/rm /var/lib/xmr_stak/cpu.txt", | |
21 | refreshonly => true, | |
22 | before => Service["xmr-stak"], | |
23 | } | |
24 | ||
25 | user { "xmr_stak": | |
26 | name => "xmr_stak", | |
27 | ensure => "present", | |
28 | managehome => true, | |
29 | home => "/var/lib/xmr_stak", | |
30 | system => true, | |
31 | password => "!!", | |
32 | require => Aur::Package["xmr-stak"], | |
33 | } | |
34 | ||
35 | file { "/etc/systemd/system/xmr-stak.service": | |
36 | mode => "0644", | |
37 | owner => "root", | |
38 | group => "root", | |
39 | content => template("profile/xmr_stak/xmr-stak.service.erb"), | |
40 | require => User["xmr_stak"], | |
41 | notify => Exec["systemctl daemon-reload"] | |
42 | } | |
43 | ||
44 | $instance = regsubst(lookup("base_installation::ldap_cn"), '\.', "_", "G") | |
45 | ||
46 | file { "/var/lib/xmr_stak/xmr-stak.conf": | |
47 | mode => "0644", | |
48 | owner => "root", | |
49 | group => "root", | |
50 | content => template("profile/xmr_stak/xmr-stak.conf.erb"), | |
51 | require => User["xmr_stak"], | |
52 | } | |
53 | ||
54 | service { "xmr-stak": | |
55 | enable => true, | |
56 | ensure => "running", | |
57 | subscribe => [ | |
58 | Aur::Package["xmr-stak"], | |
59 | File["/var/lib/xmr_stak/xmr-stak.conf"], | |
60 | File["/etc/systemd/system/xmr-stak.service"] | |
61 | ], | |
62 | require => [ | |
63 | Aur::Package["xmr-stak"], | |
64 | File["/var/lib/xmr_stak/xmr-stak.conf"], | |
65 | File["/etc/systemd/system/xmr-stak.service"] | |
66 | ] | |
67 | } | |
68 | } | |
69 | } | |
70 |