blob: c6514baadc225a0d2a1bac593e99d24fddb60e3c (
plain)
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
|
<!-- NotesAutoMatingContainerUpdates, Version: 1, Modified: 2018/12/02, Author: trac -->
# Notes: Automating Container Updates
This would have worked in an lxc only world...
```sh
#!/bin/bash
# Purpose: Update all lxc vms
# Note: Tested on Ubuntu LTS only
# Author: Vivek Gite <www.cyberciti.biz>, under GPL v2+
# -------------------------------------------------------
# Get the vm list
vms="$(lxc-ls --active)"
# Update each vm
update_vm(){
local vm="$1"
echo "*** [VM: $vm [$(hostname) @ $(date)] ] ***"
/usr/bin/lxc-attach -n "$vm" apt-get -- -qq update
/usr/bin/lxc-attach -n "$vm" apt-get -- -qq -y upgrade
/usr/bin/lxc-attach -n "$vm" apt-get -- -qq -y clean
/usr/bin/lxc-attach -n "$vm" apt-get -- -qq -y autoclean
# Note for RHEL/CentOS/Fedora Linux comment above two line and uncomment the following line #
# lxc-attach -n "$vm" yum -y update
echo "-----------------------------------------------------------------"
}
# Do it
for v in $vms
do
update_vm "$v"
done
```
This works for updating everything debian under the lxd.. Not sure you need anything else :)
```sh
Shell Fragment for looking at os distribution.
# Determine OS platform
UNAME=$(uname | tr "[:upper:]" "[:lower:]")
# If Linux, try to determine specific distribution
if [ "$UNAME" == "linux" ]; then
# If available, use LSB to identify distribution
if [ -f /etc/lsb-release -o -d /etc/lsb-release.d ]; then
export DISTRO=$(lsb_release -i | cut -d: -f2 | sed s/'^\t'//)
# Otherwise, use release info file
else
export DISTRO=$(ls -d /etc/[A-Za-z]*[_-][rv]e[lr]* | grep -v "lsb" | cut -d'/' -f3 | cut -d'-' -f1 | cut -d'_' -f1)
fi
fi
# For everything else (or if above failed), just use generic identifier
[ "$DISTRO" == "" ] && export DISTRO=$UNAME
unset UNAME
```
### Linkdump
* https://askubuntu.com/questions/459402/how-to-know-if-the-running-platform-is-ubuntu-or-centos-with-help-of-a-bash-scri
* https://ask.fedoraproject.org/en/question/49738/how-to-check-if-system-is-rpm-or-debian-based/
* http://fuckingshellscripts.org/
* https://etbe.coker.com.au/2007/08/30/identifying-the-distribution-of-a-linux-system/
* https://ask.fedoraproject.org/en/question/49738/how-to-check-if-system-is-rpm-or-debian-based/
* https://hvops.com/articles/ansible-vs-shell-scripts/
* https://news.ycombinator.com/item?id=6431552
* https://www.cyberciti.biz/faq/how-to-update-debian-or-ubuntu-linux-containers-lxc/
* https://blog.sleeplessbeastie.eu/2017/08/21/how-to-upgrade-lxd-guests/
* https://blog.selectel.com/managing-containers-lxd-brief-introduction/
* http://xmodulo.com/lxc-containers-ubuntu.html
|