Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing podman support #867

Draft
wants to merge 46 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a3601d4
enable podman.socket
lunardunno Jun 26, 2024
762603f
improving podman compatibility
lunardunno Jun 26, 2024
f39b4ec
checking the result of actions, etc.
lunardunno Jun 27, 2024
b819d87
docker.io for apt-get
lunardunno Jun 27, 2024
2fc62cf
some changes
lunardunno Jun 28, 2024
5f98d38
default value for Check service
lunardunno Jun 28, 2024
c3e59bb
add aliases for podman
lunardunno Jun 29, 2024
d502f1c
correction of comment used
lunardunno Jun 29, 2024
fe5ffec
Removing aliases for podman
lunardunno Jun 29, 2024
40bb2e8
some fix
lunardunno Jun 29, 2024
8599f8f
hub search parameters have been cancelled
lunardunno Jun 29, 2024
520094d
aliases reworked
lunardunno Jun 30, 2024
832a525
improved code readability
lunardunno Jun 30, 2024
0a3f69a
sudo test
lunardunno Jun 30, 2024
a480c17
some changes
lunardunno Jul 1, 2024
2717d9f
some change
lunardunno Jul 1, 2024
388fd6a
docker version with sudo
lunardunno Jul 1, 2024
d33b84f
docker version with sudo for podman
lunardunno Jul 1, 2024
91bb378
quotes
lunardunno Jul 1, 2024
95b330b
sudo for docker version, plus test
lunardunno Jul 1, 2024
886ca3f
test2
lunardunno Jul 1, 2024
5c9ab51
tests removed
lunardunno Jul 1, 2024
2f91240
printf aliases
lunardunno Jul 1, 2024
37cddd7
Using grep exit code
lunardunno Jul 17, 2024
40e1130
Using grep exit code
lunardunno Jul 17, 2024
467459e
check wheel group
lunardunno Jul 17, 2024
fa5e254
check sudo or wheel group
lunardunno Jul 17, 2024
d1b3c05
Removing quotes
lunardunno Jul 18, 2024
df743b0
Improved code readability
lunardunno Jul 18, 2024
df10271
Changes 1
lunardunno Jul 18, 2024
ef902e6
Changes 2
lunardunno Jul 19, 2024
3fc1a51
docker search with sudo
lunardunno Jul 19, 2024
4f77d7b
creating services for podman
lunardunno Jul 20, 2024
284019f
Create service for podman
lunardunno Jul 20, 2024
88b1664
changing restart method
lunardunno Jul 20, 2024
c34c7f2
removed creating services
lunardunno Jul 20, 2024
a9bf2df
removing stdout about creating services
lunardunno Jul 20, 2024
0f0b644
some fix
lunardunno Jul 20, 2024
65b3015
removing stderr about creating services
lunardunno Jul 20, 2024
3c239ec
enable now service for podman
lunardunno Jul 21, 2024
3676027
removing space
lunardunno Jul 21, 2024
f42fe9d
restart-policy always for podman
lunardunno Jul 21, 2024
343a5fd
renaming service file for podman
lunardunno Jul 21, 2024
76b01bc
removing service for podman
lunardunno Jul 21, 2024
92e33f6
Clearing server for podman
lunardunno Jul 21, 2024
edee3fe
Removing service for podman
lunardunno Jul 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/core/controllers/serverController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ ErrorCode ServerController::isUserInSudo(const ServerCredentials &credentials, D
const QString scriptData = amnezia::scriptData(SharedScriptType::check_user_in_sudo);
ErrorCode error = runScript(credentials, replaceVars(scriptData, genVarsForScript(credentials)), cbReadStdOut, cbReadStdErr);

if (!stdOut.contains("sudo"))
if (!stdOut.contains("sudo") && !stdOut.contains("wheel"))
return ErrorCode::ServerUserNotInSudo;

return error;
Expand Down
7 changes: 6 additions & 1 deletion client/server_scripts/awg/run_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ sudo docker run -d \
--name $CONTAINER_NAME \
$CONTAINER_NAME

# Create service for podman
if [ -n "$(sudo docker --version 2>/dev/null | grep podman)" ]; then \
sudo sh -c "podman generate systemd --restart-policy=always -t 1 --name $CONTAINER_NAME 2>/dev/null > $DOCKERFILE_FOLDER/container-$CONTAINER_NAME.service";\
sudo sh -c "systemctl enable --now $DOCKERFILE_FOLDER/container-$CONTAINER_NAME.service && docker update --restart no $CONTAINER_NAME > /dev/null";\
fi

sudo docker network connect amnezia-dns-net $CONTAINER_NAME

# Prevent to route packets outside of the container in case if server behind of the NAT
#sudo docker exec -i $CONTAINER_NAME sh -c "ifconfig eth0:0 $SERVER_IP_ADDRESS netmask 255.255.255.255 up"

17 changes: 17 additions & 0 deletions client/server_scripts/build_container.sh
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
if [ -n "$(sudo docker --version 2>/dev/null | grep podman)" ]; then sudo sh -c "\
test -d /var/cache/containers || mkdir -m 700 -p /var/cache/containers;\
test -f /var/cache/containers/short-name-aliases.conf || chmod 600 /var/cache/containers/short-name-aliases.conf>>/var/cache/containers/short-name-aliases.conf;\
grep -q '\[aliases\]' /var/cache/containers/short-name-aliases.conf || echo '[aliases]' >> /var/cache/containers/short-name-aliases.conf;\
grep -q ' # Amnezia start' /var/cache/containers/short-name-aliases.conf || printf '%s\n' \
' # Amnezia start' \
' \"3proxy/3proxy\" = \"docker.io/3proxy/3proxy\"' \
' \"amneziavpn/amnezia-wg\" = \"docker.io/amneziavpn/amnezia-wg\"' \
' \"amneziavpn/amneziawg-go\" = \"docker.io/amneziavpn/amneziawg-go\"' \
' \"amneziavpn/ipsec-server\" = \"docker.io/amneziavpn/ipsec-server\"' \
' \"amneziavpn/torpress\" = \"docker.io/amneziavpn/torpress\"' \
' \"atmoz/sftp\" = \"docker.io/atmoz/sftp\"' \
' \"mvance/unbound\" = \"docker.io/mvance/unbound\"' \
' \"alpine\" = \"docker.io/library/alpine\"' \
' # Amnezia finish' \
>> /var/cache/containers/short-name-aliases.conf";\
fi;\
sudo docker build --no-cache --pull -t $CONTAINER_NAME $DOCKERFILE_FOLDER
42 changes: 27 additions & 15 deletions client/server_scripts/install_docker.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
if which apt-get > /dev/null 2>&1; then pm=$(which apt-get); silent_inst="-yq install"; check_pkgs="-yq update"; docker_pkg="docker.io"; dist="debian";\
elif which dnf > /dev/null 2>&1; then pm=$(which dnf); silent_inst="-yq install"; check_pkgs="-yq check-update"; docker_pkg="docker"; dist="fedora";\
elif which yum > /dev/null 2>&1; then pm=$(which yum); silent_inst="-y -q install"; check_pkgs="-y -q check-update"; docker_pkg="docker"; dist="centos";\
elif which pacman > /dev/null 2>&1; then pm=$(which pacman); silent_inst="-S --noconfirm --noprogressbar --quiet"; check_pkgs="> /dev/null 2>&1"; docker_pkg="docker"; dist="archlinux";\
if which apt-get > /dev/null 2>&1; then pm=$(which apt-get); silent_inst="-yq install"; check_pkgs="-yq update"; wh_pkg="-s install"; docker_pkg="docker.io"; check_srv="docker"; dist="debian";\
elif which dnf > /dev/null 2>&1; then pm=$(which dnf); silent_inst="-yq install"; check_pkgs="-yq check-update"; wh_pkg="--assumeno install --setopt=tsflags=test"; docker_pkg="docker"; check_srv="docker"; dist="fedora";\
elif which yum > /dev/null 2>&1; then pm=$(which yum); silent_inst="-y -q install"; check_pkgs="-y -q check-update"; wh_pkg="--assumeno install --setopt=tsflags=test"; docker_pkg="docker"; check_srv="docker"; dist="centos";\
elif which pacman > /dev/null 2>&1; then pm=$(which pacman); silent_inst="-S --noconfirm --noprogressbar --quiet"; check_pkgs="-Sup"; wh_pkg="-Sp"; docker_pkg="docker"; check_srv="docker"; dist="archlinux";\
else echo "Packet manager not found"; exit 1; fi;\
echo "Dist: $dist, Packet manager: $pm, Install command: $silent_inst, Check pkgs command: $check_pkgs, Docker pkg: $docker_pkg";\
echo "Dist: $dist, Packet manager: $pm, Install command: $silent_inst, Check pkgs command: $check_pkgs, What pkg command: $wh_pkg, Docker pkg: $docker_pkg, Check service: $check_srv";\
if [ "$dist" = "debian" ]; then export DEBIAN_FRONTEND=noninteractive; fi;\
if ! command -v sudo > /dev/null 2>&1; then $pm $check_pkgs; $pm $silent_inst sudo; fi;\
if ! command -v fuser > /dev/null 2>&1; then sudo $pm $check_pkgs; sudo $pm $silent_inst psmisc; fi;\
if ! command -v lsof > /dev/null 2>&1; then sudo $pm $check_pkgs; sudo $pm $silent_inst lsof; fi;\
if ! command -v docker > /dev/null 2>&1; then \
sudo $pm $check_pkgs; sudo $pm $silent_inst $docker_pkg;\
sleep 5; sudo systemctl enable --now docker; sleep 5;\
if [ -z "$(echo $LANG | grep -E 'en_US.UTF-8|C.UTF-8')" ]; then \
if [ -n "$(locale -a | grep en_US.utf8)" ]; then export LC_ALL=en_US.UTF-8;\
elif [ -n "$(locale -a | grep C.utf8)" ]; then export LC_ALL=C.UTF-8;\
fi;\
fi;\
if ! command -v sudo > /dev/null 2>&1; then $pm $check_pkgs; $pm $silent_inst sudo || sudo 2>&1 > /dev/null || exit 1; fi;\
if ! command -v fuser > /dev/null 2>&1; then sudo $pm $check_pkgs; sudo $pm $silent_inst psmisc || fuser 2>&1 > /dev/null || exit 1; fi;\
if ! command -v lsof > /dev/null 2>&1; then sudo $pm $check_pkgs; sudo $pm $silent_inst lsof || lsof 2>&1 > /dev/null || exit 1; fi;\
if ! command -v docker > /dev/null 2>&1; then sudo $pm $check_pkgs;\
if [ -n "$(sudo $pm $wh_pkg $docker_pkg 2>/dev/null | grep moby-engine)" ]; then echo "Docker is not supported"; echo "command not found"; exit 1;\
else sudo $pm $silent_inst $docker_pkg || docker 2>&1 > /dev/null || exit 1;\
fi;\
if [ -n "$(sudo docker --version 2>/dev/null | grep podman)" ]; then check_srv="podman.socket podman"; sudo touch /etc/containers/nodocker; fi;\
sleep 5; sudo systemctl enable --now $check_srv 2>/dev/null; sleep 5;\
fi;\
if [ -n "$(sudo docker --version 2>&1 | grep moby-engine)" ]; then echo "Docker is not supported"; echo "command not found"; exit 1;\
elif [ -n "$(sudo docker --version 2>&1 | grep podman)" ]; then check_srv="podman.socket podman"; docker_pkg="podman-docker";\
if [ -n "$(sudo docker --version 2>&1 | grep /etc/containers/nodocker)" ]; then sudo touch /etc/containers/nodocker; fi;\
fi;\
if [ "$(systemctl is-active docker)" != "active" ]; then \
if [ "$(systemctl is-active $check_srv | head -n1)" != "active" ]; then \
sudo $pm $check_pkgs; sudo $pm $silent_inst $docker_pkg;\
sleep 5; sudo systemctl start docker; sleep 5;\
sleep 5; sudo systemctl start $check_srv; sleep 5;\
if [ "$(systemctl is-active $check_srv | head -n1)" != "active" ]; then echo "Failed to status docker"; echo "command not found"; exit 1; fi;\
fi;\
if ! command -v sudo > /dev/null 2>&1; then echo "Failed to install sudo, command not found"; exit 1; fi;\
docker --version
sudo docker --version
4 changes: 4 additions & 0 deletions client/server_scripts/remove_all_containers.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
sudo docker ps -a | grep amnezia | awk '{print $1}' | xargs sudo docker stop;\
sudo docker --version 2>/dev/null | grep -q podman && \
sudo systemctl list-units | grep amnezia | awk '{print $1}' | xargs sudo systemctl disable --now && \
sudo systemctl daemon-reload && sudo systemctl reset-failed && \
sudo sed -i '/^ # Amnezia start/,/^ # Amnezia finish$/d' /var/cache/containers/short-name-aliases.conf;\
sudo docker ps -a | grep amnezia | awk '{print $1}' | xargs sudo docker rm -fv;\
sudo docker images -a | grep amnezia | awk '{print $3}' | xargs sudo docker rmi;\
sudo docker network ls | grep amnezia-dns-net | awk '{print $1}' | xargs sudo docker network rm;\
Expand Down
4 changes: 4 additions & 0 deletions client/server_scripts/remove_container.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
sudo docker stop $CONTAINER_NAME;\
sudo docker --version 2>/dev/null | grep -q podman && \
sudo systemctl disable --now container-$CONTAINER_NAME.service && \
sudo systemctl daemon-reload && sudo systemctl reset-failed && \
sudo rm -f $DOCKERFILE_FOLDER/container-$CONTAINER_NAME.service;\
sudo docker rm -fv $CONTAINER_NAME;\
sudo docker rmi $CONTAINER_NAME
Loading