Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3052684

Browse filesBrowse files
develop
1 parent d15a7bb commit 3052684
Copy full SHA for 3052684

File tree

Expand file treeCollapse file tree

344 files changed

+13433
-13
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

344 files changed

+13433
-13
lines changed

‎.appveyor.yml

Copy file name to clipboard
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
environment:
2+
matrix:
3+
- APPVEYOR_BUILD_WORKER_IMAGE: ubuntu1804
4+
PYTHON_VERSION: 3.8
5+
TOXENV: py38
6+
stack: python $(PYTHON_VERSION)
7+
clone_depth: 10
8+
branches:
9+
only:
10+
- master
11+
- /develop/
12+
build: false
13+
install:
14+
- sudo apt-get -y update
15+
- sudo apt-get -y install attr systemd-container
16+
- pip install tox
17+
test_script:
18+
- echo $HOME
19+
- uname -a
20+
- ip addr
21+
- python --version
22+
- systemctl --version
23+
- getfattr --dump /home
24+
- tox

‎.gitignore

Copy file name to clipboardExpand all lines: .gitignore
+13-12Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ __pycache__/
88

99
# Distribution / packaging
1010
.Python
11-
build/
12-
develop-eggs/
13-
dist/
14-
downloads/
15-
eggs/
16-
.eggs/
17-
lib/
18-
lib64/
19-
parts/
20-
sdist/
21-
var/
22-
wheels/
11+
/build/
12+
/develop-eggs/
13+
/dist/
14+
/downloads/
15+
/eggs/
16+
/.eggs/
17+
/lib/
18+
/lib64/
19+
/parts/
20+
/sdist/
21+
/var/
22+
/wheels/
2323
*.egg-info/
2424
.installed.cfg
2525
*.egg
@@ -89,6 +89,7 @@ venv/
8989
ENV/
9090
env.bak/
9191
venv.bak/
92+
.pyenv/
9293

9394
# Spyder project settings
9495
.spyderproject

‎.travis.yml

Copy file name to clipboard
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
dist: xenial
2+
sudo: true
3+
language: python
4+
git:
5+
depth: 10
6+
branches:
7+
only:
8+
- master
9+
- /develop/
10+
matrix:
11+
include:
12+
- python: 3.8
13+
env: TOXENV=py38
14+
install:
15+
- sudo apt-get -y update
16+
- sudo apt-get -y install attr pigz systemd-container
17+
- pip install tox devrepo
18+
script:
19+
- echo $HOME
20+
- uname -a
21+
- ip addr
22+
- python --version
23+
- systemctl --version
24+
- getfattr --dump /home
25+
- tox

‎README.md

Copy file name to clipboardExpand all lines: README.md
-1Lines changed: 0 additions & 1 deletion
This file was deleted.

‎demo/alpine-base.service

Copy file name to clipboard
+87Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
2+
# Machine Container with systemd-nspawn.
3+
4+
[Unit]
5+
6+
Description=alpine-base
7+
8+
Documentation=https://github.com/random-python/nspawn
9+
10+
PartOf=machines.target
11+
Before=machines.target
12+
After=network.target
13+
After=network-online.target
14+
Requires=network-online.target
15+
16+
# Verify machine root overlay resources:
17+
AssertPathExists=/var/lib/nspawn/extract/localhost/tmp/nspawn/repo/alpine/base/default-3.9.4-x86_64.tar.gz/
18+
AssertPathExists=/var/lib/nspawn/extract/dl-cdn.alpinelinux.org/alpine/v3.9/releases/x86_64/alpine-minirootfs-3.9.4-x86_64.tar.gz/
19+
20+
[Service]
21+
22+
# Release machine root overlay mount.
23+
Environment="SYSTEMD_NSPAWN_LOCK=false"
24+
25+
# Ensure host bind/overlay resources:
26+
ExecStartPre=/usr/bin/mkdir -p /root/.ssh
27+
ExecStartPre=/usr/bin/touch -a /root/.ssh/authorized_keys
28+
29+
# Container resource create:
30+
ExecStartPre=/usr/bin/mkdir -p /var/lib/nspawn/runtime/alpine-base
31+
ExecStartPre=/usr/bin/mkdir -p /var/lib/nspawn/runtime/alpine-base/root
32+
ExecStartPre=/usr/bin/mkdir -p /var/lib/nspawn/runtime/alpine-base/work
33+
ExecStartPre=/usr/bin/mkdir -p /var/lib/nspawn/runtime/alpine-base/zero
34+
ExecStartPre=/usr/bin/mkdir -p /var/lib/machines/alpine-base
35+
ExecStartPre=/usr/bin/mount -t overlay -o lowerdir=/var/lib/nspawn/extract/localhost/tmp/nspawn/repo/alpine/base/default-3.9.4-x86_64.tar.gz/:/var/lib/nspawn/extract/dl-cdn.alpinelinux.org/alpine/v3.9/releases/x86_64/alpine-minirootfs-3.9.4-x86_64.tar.gz/:/var/lib/nspawn/runtime/alpine-base/zero,upperdir=/var/lib/nspawn/runtime/alpine-base/root,workdir=/var/lib/nspawn/runtime/alpine-base/work overlay /var/lib/machines/alpine-base
36+
37+
# Container settings origin report:
38+
# --kill-signal=SIGUSR1 :: file://localhost/tmp/nspawn/repo/alpine/base/default-3.9.4-x86_64.tar.gz
39+
# --boot :: file:///home/work/source/git/nspawn/demo/alpine/base/setup.py
40+
# --quiet :: file:///home/work/source/git/nspawn/demo/alpine/base/setup.py
41+
# --keep-unit :: file:///home/work/source/git/nspawn/demo/alpine/base/setup.py
42+
# --register=yes :: file:///home/work/source/git/nspawn/demo/alpine/base/setup.py
43+
# --network-macvlan=wire0 :: file:///home/work/source/git/nspawn/demo/alpine/base/setup.py
44+
# --bind-ro=/root/.ssh/authorized_keys :: file:///home/work/source/git/nspawn/demo/alpine/base/setup.py
45+
46+
# Container instance launch:
47+
ExecStart=/usr/bin/systemd-nspawn \
48+
--machine=alpine-base \
49+
--directory=/var/lib/machines/alpine-base \
50+
--kill-signal='SIGUSR1' \
51+
--boot \
52+
--quiet \
53+
--keep-unit \
54+
--register='yes' \
55+
--network-macvlan='wire0' \
56+
--bind-ro='/root/.ssh/authorized_keys'
57+
58+
# Container instance finish:
59+
ExecStop=/usr/bin/true
60+
61+
# Container resource delete:
62+
ExecStopPost=/usr/bin/umount /var/lib/machines/alpine-base
63+
ExecStopPost=/usr/bin/rm -r -f /var/lib/machines/alpine-base
64+
ExecStopPost=/usr/bin/rm -r -f /var/lib/nspawn/runtime/alpine-base
65+
66+
# Machine name for journal:
67+
SyslogIdentifier=alpine-base
68+
69+
Type=notify
70+
KillMode=mixed
71+
Slice=machine.slice
72+
Delegate=yes
73+
TasksMax=16384
74+
75+
RestartSec=3s
76+
TimeoutStartSec=5s
77+
TimeoutStopSec=5s
78+
79+
WatchdogSec=3min
80+
81+
# Return code 133 = 128 + 5 = <terminated by signal> + SIGTRAP
82+
SuccessExitStatus=133
83+
RestartForceExitStatus=133
84+
85+
[Install]
86+
87+
WantedBy=machines.target

‎demo/alpine/base/build.py

Copy file name to clipboard
+52Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python
2+
3+
# activate build dsl
4+
from nspawn.build import *
5+
6+
# define image url
7+
import platform
8+
epoch = "3.9"
9+
release = f"{epoch}.4"
10+
hardware = platform.machine()
11+
image_url = f"file://localhost/tmp/nspawn/repo/alpine/base/default-{release}-{hardware}.tar.gz"
12+
alpine_url = f"http://dl-cdn.alpinelinux.org/alpine/v{epoch}/releases/{hardware}/alpine-minirootfs-{release}-{hardware}.tar.gz"
13+
14+
# declare image identity
15+
IMAGE(image_url)
16+
17+
# provision dependency image
18+
PULL(alpine_url)
19+
20+
# termination for alpine /sbin/init (i.e. /bin/busybox)
21+
WITH(KillSignal="SIGUSR1")
22+
23+
# copy local resources
24+
COPY("/etc")
25+
COPY("/root")
26+
27+
# template local resources
28+
CAST("/root/readme.md", variable="template varialbe")
29+
30+
# invoke some bild program
31+
RUN(["/usr/bin/env"])
32+
33+
# invoke build shell script
34+
SH("apk update")
35+
SH("apk upgrade")
36+
SH("apk add tzdata")
37+
SH("apk add ca-certificates")
38+
SH("apk add busybox-initscripts")
39+
SH("apk add mc htop pwgen")
40+
SH("apk add iputils iproute2")
41+
SH("apk add dhcpcd openssh ")
42+
SH("rc-update add syslog")
43+
SH("rc-update add dhcpcd")
44+
SH("rc-update add sshd")
45+
SH("""
46+
echo 'PubkeyAuthentication yes' >> /etc/ssh/sshd_config
47+
echo 'PasswordAuthentication no' >> /etc/ssh/sshd_config
48+
user=root; pass=$(pwgen 64 1); echo $user:$pass | chpasswd
49+
""")
50+
51+
# publish image to image url
52+
PUSH()

‎demo/alpine/base/etc/inittab

Copy file name to clipboard
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# /etc/inittab
2+
# https://github.com/alpinelinux/alpine-baselayout/blob/master/inittab
3+
4+
::sysinit:/sbin/rc sysinit
5+
::wait:/sbin/rc default
6+
7+
# Set up a couple of getty's
8+
#tty1::respawn:/sbin/getty 38400 tty1
9+
#tty2::respawn:/sbin/getty 38400 tty2
10+
#tty3::respawn:/sbin/getty 38400 tty3
11+
12+
# Put a getty on the serial port
13+
#ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100
14+
15+
# Put a getty on the console
16+
console::respawn:/sbin/getty 115200,38400,9600 console
17+
18+
# Stuff to do for the 3-finger salute
19+
::ctrlaltdel:/sbin/reboot
20+
21+
# Stuff to do before rebooting
22+
::shutdown:/sbin/rc shutdown

‎demo/alpine/base/etc/motd

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# message of the day
3+
#
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#
2+
# https://wiki.alpinelinux.org/wiki/Configure_Networking
3+
#
4+
5+
auto lo
6+
iface lo inet loopback

‎demo/alpine/base/root/.ssh/readme.md

Copy file name to clipboard
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
### note
3+
4+
ensure proper chmod: no go=rx on */.ssh path

‎demo/alpine/base/root/readme.md

Copy file name to clipboard
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
### root
3+
4+
variable="{{variable}}"

‎demo/alpine/base/setup.py

Copy file name to clipboard
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python
2+
3+
# activate setup dsl
4+
from nspawn.setup import *
5+
6+
# define image url
7+
import platform
8+
epoch = "3.9"
9+
release = f"{epoch}.4"
10+
hardware = platform.machine()
11+
image_url = f"file://localhost/tmp/nspawn/repo/alpine/base/default-{release}-{hardware}.tar.gz"
12+
13+
# discover network interface
14+
network_face = TOOL.select_interface()
15+
16+
# declare machine image
17+
IMAGE(url=image_url)
18+
19+
# provide machine identity
20+
MACHINE(name="alpine-base") # sets default hostname
21+
22+
# customize machine service
23+
WITH(
24+
# Hostname="alpase", # needs systemd v 239
25+
Boot="yes", # locate /bin/init automatically
26+
Quiet="yes", # suppress "press to escape" message
27+
KeepUnit="yes", # use service unit as nspawn scope
28+
Register="yes", # expose service unit with machinectl
29+
MACVLAN=network_face, # create a "macvlan" interface of the specified network interface and add it to the container
30+
)
31+
32+
# configure machine ssh access
33+
WITH(BindReadOnly="/root/.ssh/authorized_keys")

‎demo/alpine/readme.md

Copy file name to clipboard
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
### alpine linux
3+
4+
https://alpinelinux.org/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.