Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

Commit

Permalink
cleanup improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
moshloop committed Jun 26, 2019
1 parent c12d995 commit 426d358
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions pkg/apps/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,18 @@ func (c cleanup) ApplyPhase(sys *Config, ctx *SystemContext) ([]Command, Filesys
}

cmds.Add("rm -rf /tmp/* || true").
Add("rm -rf /var/log/cloud-init* || true").
Add("rm -rf /usr/share/man/* || true").
Add("rm -rf /usr/share/doc/* || true").
Add("rm /etc/udev/rules.d/70-persistent-net.rules || true").
Add("rm -f /etc/ssh/{ssh_host_dsa_key,ssh_host_dsa_key.pub,ssh_host_ecdsa_key,ssh_host_ecdsa_key.pub,ssh_host_ed25519_key,ssh_host_ed25519_key.pub,ssh_host_rsa_key,ssh_host_rsa_key.pub} || true").
Add("find /var/cache -type f -exec rm -rf {} \\;").
Add("find /var/log -type f | while read -r f; do echo -ne '' > \"$f\"; done;").
Add("cloud-init clean || true")
Add("sed -i '/^\\(HWADDR\\|UUID\\)=/d' /etc/sysconfig/network-scripts/ifcfg-* || true").
Add("rm -rf /var/lib/cloud/* || true").
Add("dd if=/dev/zero of=/EMPTY bs=1M 2>/dev/null || true; rm -f /EMPTY")

fs["/root/.bash_profile"] = File{Content: "shopt -s histappend"}
fs["/etc/machine-id"] = File{Content: ""}
fs["/root/.bash_history"] = File{Content: ""}
fs["/root/.bashrc"] = File{Content: ""}

// TODO
// dd if=/dev/zero of=/EMPTY bs=1M 2>/dev/null || echo "dd exit code $? is suppressed"
// rm -f /EMPTY
//redhat
//sed -i '/^\(HWADDR\|UUID\)=/d' /etc/sysconfig/network-scripts/ifcfg-*
//debian /etc/udev/rules.d/70-persistent-net.rules

return cmds.GetCommands(), fs, nil
}

0 comments on commit 426d358

Please sign in to comment.