This repository has been archived by the owner on Jun 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
debian.go
79 lines (63 loc) · 1.88 KB
/
debian.go
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package phases
import (
"strings"
"github.com/flanksource/konfigadm/pkg/types"
"github.com/flanksource/konfigadm/pkg/utils"
)
var (
Ubuntu = ubuntu{}
Debian = debian{}
)
type ubuntu struct {
}
func (u ubuntu) String() string {
return "ubuntu"
}
func (u ubuntu) GetPackageManager() types.PackageManager {
return AptPackageManager{}
}
func (u ubuntu) GetTags() []types.Flag {
return []types.Flag{types.UBUNTU, types.DEBIAN_LIKE}
}
func (u ubuntu) DetectAtRuntime() bool {
return strings.Contains(utils.SafeRead("/etc/os-release"), "Ubuntu")
}
func (u ubuntu) GetVersionCodeName() string {
return utils.IniToMap("/etc/os-release")["VERSION_CODENAME"]
}
type debian struct {
}
func (d debian) String() string {
return "debian"
}
func (d debian) GetPackageManager() types.PackageManager {
return AptPackageManager{}
}
func (d debian) GetTags() []types.Flag {
return []types.Flag{types.DEBIAN, types.DEBIAN_LIKE}
}
func (d debian) DetectAtRuntime() bool {
return strings.Contains(utils.SafeRead("/etc/os-release"), "Debian")
}
func (d debian) GetVersionCodeName() string {
return utils.IniToMap("/etc/os-release")["VERSION_CODENAME"]
}
func (d debian) Cleanup() string {
return `
unset HISTFILE
find /var/log -type f | while read f; do echo -ne '' > "${f}"; done;
UBUNTU_VERSION=$(lsb_release -sr)
if [[ ${UBUNTU_VERSION} == 16.04 ]] || [[ ${UBUNTU_VERSION} == 16.10 ]]; then
# Modified version of
# https://github.com/cbednarski/packer-ubuntu/blob/master/scripts-1604/vm_cleanup.sh#L9-L15
# Instead of eth0 the interface is now called ens5 to mach the PCI
# slot, so we need to change the networking scripts to enable the
# correct interface.
#
# NOTE: After the machine is rebooted Packer will not be able to reconnect
# (Vagrant will be able to) so make sure this is done in your final
# provisioner.
sed -i "s/ens3/ens5/g" /etc/network/interfaces
fi
`
}