Skip to content

Commit 10c4672

Browse files
authored
Add ZFS to Podman. Now it works on ZFS! (#2526)
* Allow Podman to work on ZFS containers * Fix ZFS for Podman-Create missing folder. * Added option to install Portainer or Portainer agent in Podman * Fix source for Podman Homeassistant so Portainer and other containers can be installed. * fix Podman not creating storage/volumes, until one exists.
1 parent 666e170 commit 10c4672

File tree

4 files changed

+127
-5
lines changed

4 files changed

+127
-5
lines changed

install/podman-homeassistant-install.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,72 @@ $STD apt-get install -y sudo
1919
$STD apt-get install -y mc
2020
msg_ok "Installed Dependencies"
2121

22+
get_latest_release() {
23+
curl -sL https://api.github.com/repos/$1/releases/latest | grep '"tag_name":' | cut -d'"' -f4
24+
}
25+
26+
PORTAINER_LATEST_VERSION=$(get_latest_release "portainer/portainer")
27+
PORTAINER_AGENT_LATEST_VERSION=$(get_latest_release "portainer/agent")
28+
29+
if $STD mount | grep 'on / type zfs' > null && echo "ZFS"; then
30+
msg_info "Enabling ZFS support."
31+
mkdir -p /etc/containers
32+
cat <<'EOF' >/usr/local/bin/overlayzfsmount
33+
#!/bin/sh
34+
exec /bin/mount -t overlay overlay "$@"
35+
EOF
36+
chmod +x /usr/local/bin/overlayzfsmount
37+
cat <<'EOF' >/etc/containers/storage.conf
38+
[storage]
39+
driver = "overlay"
40+
runroot = "/run/containers/storage"
41+
graphroot = "/var/lib/containers/storage"
42+
43+
[storage.options]
44+
pull_options = {enable_partial_images = "false", use_hard_links = "false", ostree_repos=""}
45+
mount_program = "/usr/local/bin/overlayzfsmount"
46+
47+
[storage.options.overlay]
48+
mountopt = "nodev"
49+
EOF
50+
fi
51+
2252
msg_info "Installing Podman"
2353
$STD apt-get -y install podman
2454
$STD systemctl enable --now podman.socket
55+
echo -e 'unqualified-search-registries=["docker.io"]' >> /etc/containers/registries.conf
2556
msg_ok "Installed Podman"
2657

58+
read -r -p "Would you like to add Portainer? <y/N> " prompt
59+
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
60+
msg_info "Installing Portainer $PORTAINER_LATEST_VERSION"
61+
podman volume create portainer_data >/dev/null
62+
$STD podman run -d \
63+
-p 8000:8000 \
64+
-p 9443:9443 \
65+
--name=portainer \
66+
--restart=always \
67+
-v /run/podman/podman.sock:/var/run/docker.sock \
68+
-v portainer_data:/data \
69+
portainer/portainer-ce:latest
70+
msg_ok "Installed Portainer $PORTAINER_LATEST_VERSION"
71+
else
72+
read -r -p "Would you like to add the Portainer Agent? <y/N> " prompt
73+
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
74+
msg_info "Installing Portainer agent $PORTAINER_AGENT_LATEST_VERSION"
75+
podman volume create temp >/dev/null
76+
podman volume remove temp >/dev/null
77+
$STD podman run -d \
78+
-p 9001:9001 \
79+
--name portainer_agent \
80+
--restart=always \
81+
-v /run/podman/podman.sock:/var/run/docker.sock \
82+
-v /var/lib/containers/storage/volumes:/var/lib/docker/volumes \
83+
portainer/agent
84+
msg_ok "Installed Portainer Agent $PORTAINER_AGENT_LATEST_VERSION"
85+
fi
86+
fi
87+
2788
msg_info "Pulling Home Assistant Image"
2889
$STD podman pull docker.io/homeassistant/home-assistant:stable
2990
msg_ok "Pulled Home Assistant Image"

install/podman-install.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,73 @@ $STD apt-get install -y sudo
1919
$STD apt-get install -y mc
2020
msg_ok "Installed Dependencies"
2121

22+
get_latest_release() {
23+
curl -sL https://api.github.com/repos/$1/releases/latest | grep '"tag_name":' | cut -d'"' -f4
24+
}
25+
26+
PORTAINER_LATEST_VERSION=$(get_latest_release "portainer/portainer")
27+
PORTAINER_AGENT_LATEST_VERSION=$(get_latest_release "portainer/agent")
28+
29+
if $STD mount | grep 'on / type zfs' > null && echo "ZFS"; then
30+
msg_info "Enabling ZFS support."
31+
mkdir -p /etc/containers
32+
cat <<'EOF' >/usr/local/bin/overlayzfsmount
33+
#!/bin/sh
34+
exec /bin/mount -t overlay overlay "$@"
35+
EOF
36+
chmod +x /usr/local/bin/overlayzfsmount
37+
cat <<'EOF' >/etc/containers/storage.conf
38+
[storage]
39+
driver = "overlay"
40+
runroot = "/run/containers/storage"
41+
graphroot = "/var/lib/containers/storage"
42+
43+
[storage.options]
44+
pull_options = {enable_partial_images = "false", use_hard_links = "false", ostree_repos=""}
45+
mount_program = "/usr/local/bin/overlayzfsmount"
46+
47+
[storage.options.overlay]
48+
mountopt = "nodev"
49+
EOF
50+
fi
51+
2252
msg_info "Installing Podman"
2353
$STD apt-get -y install podman
2454
$STD systemctl enable --now podman.socket
2555
echo -e 'unqualified-search-registries=["docker.io"]' >> /etc/containers/registries.conf
2656
msg_ok "Installed Podman"
2757

58+
read -r -p "Would you like to add Portainer? <y/N> " prompt
59+
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
60+
msg_info "Installing Portainer $PORTAINER_LATEST_VERSION"
61+
podman volume create portainer_data >/dev/null
62+
$STD podman run -d \
63+
-p 8000:8000 \
64+
-p 9443:9443 \
65+
--name=portainer \
66+
--restart=always \
67+
-v /run/podman/podman.sock:/var/run/docker.sock \
68+
-v portainer_data:/data \
69+
portainer/portainer-ce:latest
70+
msg_ok "Installed Portainer $PORTAINER_LATEST_VERSION"
71+
else
72+
read -r -p "Would you like to add the Portainer Agent? <y/N> " prompt
73+
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
74+
msg_info "Installing Portainer agent $PORTAINER_AGENT_LATEST_VERSION"
75+
podman volume create temp >/dev/null
76+
podman volume remove temp >/dev/null
77+
$STD podman run -d \
78+
-p 9001:9001 \
79+
--name portainer_agent \
80+
--restart=always \
81+
-v /run/podman/podman.sock:/var/run/docker.sock \
82+
-v /var/lib/containers/storage/volumes:/var/lib/docker/volumes \
83+
portainer/agent
84+
msg_ok "Installed Portainer Agent $PORTAINER_AGENT_LATEST_VERSION"
85+
fi
86+
fi
87+
88+
2889
motd_ssh
2990
customize
3091

json/podman-homeassistant.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@
3131
"password": null
3232
},
3333
"notes": [
34-
{
35-
"text": "Doesn't work with ZFS",
36-
"type": "warning"
37-
},
3834
{
3935
"text": "If the LXC is created Privileged, the script will automatically set up USB passthrough.",
4036
"type": "warning"
4137
},
4238
{
4339
"text": "config path: `/var/lib/containers/storage/volumes/hass_config/_data`",
4440
"type": "info"
41+
},
42+
{
43+
"text": "Options to Install Portainer or Portainer Agent",
44+
"type": "warning"
4545
}
4646
]
4747
}

json/podman.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
"notes": [
3434
{
35-
"text": "Doesn't work with ZFS",
35+
"text": "Options to Install Portainer or Portainer Agent",
3636
"type": "warning"
3737
}
3838
]

0 commit comments

Comments
 (0)