Compare commits

...
Sign in to create a new pull request.

55 commits

Author SHA1 Message Date
lunardunno
393926c78e
Merge branch 'support-podman' into support_podman 2025-03-18 18:25:08 +04:00
lunardunno
ecf5b7c68f Checking sudo docker and status of the service
Checking presence Sudo and Docker on the server.
Checking the status of the Docker service.
2025-03-18 16:12:20 +04:00
lunardunno
0b6822d47b
Merge branch 'support-podman' into support_podman 2025-03-18 14:14:18 +04:00
lunardunno
ae32b26b83 Adding variables
Adding variables for the Docker service name and for checking the Docker variant being prepared for installation.
2025-03-18 14:01:41 +04:00
lunardunno
0c42563389
Removing check installation result
Removing check installation result: sudo psmisc lsof
2025-03-18 12:47:19 +04:00
lunardunno
b14431662f
Simplifying check system locale
Simplifying to check and change the system locale.
2025-03-18 12:31:40 +04:00
lunardunno
58a803335d
Implementing podman support
Implementing podman support for X-ray
2025-03-18 11:01:08 +04:00
lunardunno
8a3183f101
Merge branch 'dev' into support_podman 2025-03-15 03:40:39 +04:00
lunardunno
9b695df78d
Merge branch 'dev' into support_podman 2025-03-14 16:57:02 +04:00
lunardunno
edee3fec10
Removing service for podman 2024-07-22 02:12:52 +04:00
lunardunno
92e33f62c5
Clearing server for podman 2024-07-22 01:57:38 +04:00
lunardunno
76b01bc09a
removing service for podman 2024-07-21 07:49:08 +04:00
lunardunno
343a5fdc1a
renaming service file for podman 2024-07-21 07:46:17 +04:00
lunardunno
f42fe9dde4
restart-policy always for podman 2024-07-21 07:42:39 +04:00
lunardunno
3676027ae1
removing space 2024-07-21 05:04:21 +04:00
lunardunno
3c239ec28d
enable now service for podman 2024-07-21 04:35:51 +04:00
lunardunno
65b3015078
removing stderr about creating services
removing the output of information about creating services for podman-docker
2024-07-20 09:34:12 +04:00
lunardunno
0f0b644630
some fix 2024-07-20 09:26:12 +04:00
lunardunno
a9bf2dfcb9
removing stdout about creating services
removing the output of information about creating services for podman-docker
2024-07-20 09:09:19 +04:00
lunardunno
c34c7f21b0
removed creating services
creation of services for podman in this place has been removed
2024-07-20 09:01:07 +04:00
lunardunno
88b166443f
changing restart method
changing restart method for podman-docker
2024-07-20 08:54:13 +04:00
lunardunno
284019f954
Create service for podman 2024-07-20 07:10:41 +04:00
lunardunno
4f77d7ba70
creating services for podman
creating systemd service to autostart container when the server is rebooted, when using podman-docker
2024-07-20 06:04:17 +04:00
lunardunno
3fc1a51a4c
docker search with sudo 2024-07-20 00:39:42 +04:00
lunardunno
ef902e6ddb
Changes 2 2024-07-19 17:18:55 +04:00
lunardunno
df10271be0
Changes 1 2024-07-18 21:03:15 +04:00
lunardunno
df743b0b39
Improved code readability 2024-07-18 18:56:17 +04:00
lunardunno
d1b3c05e02
Removing quotes 2024-07-18 04:26:38 +04:00
lunardunno
fa5e254d83
check sudo or wheel group 2024-07-18 03:34:03 +04:00
lunardunno
467459e6f3
check wheel group 2024-07-18 03:08:51 +04:00
lunardunno
40e113023e
Using grep exit code 2024-07-18 00:59:41 +04:00
lunardunno
37cddd73ce
Using grep exit code 2024-07-17 21:16:55 +04:00
lunardunno
2f91240766
printf aliases 2024-07-01 17:00:14 +04:00
lunardunno
5c9ab510cb
tests removed 2024-07-01 15:13:58 +04:00
lunardunno
886ca3f6ac
test2 2024-07-01 13:55:18 +04:00
lunardunno
95b330bd56
sudo for docker version, plus test 2024-07-01 12:02:22 +04:00
lunardunno
91bb378806
quotes 2024-07-01 09:05:56 +04:00
lunardunno
d33b84f637
docker version with sudo for podman 2024-07-01 05:58:22 +04:00
lunardunno
388fd6ac46
docker version with sudo 2024-07-01 05:33:42 +04:00
lunardunno
2717d9f5c2
some change 2024-07-01 05:02:58 +04:00
lunardunno
a480c17f38
some changes 2024-07-01 04:29:01 +04:00
lunardunno
0a3f69a477
sudo test 2024-07-01 02:37:46 +04:00
lunardunno
832a525065
improved code readability 2024-06-30 16:40:05 +04:00
lunardunno
520094d430
aliases reworked
reworked the creation of aliases for podman for users with sudo
2024-06-30 12:45:40 +04:00
lunardunno
8599f8f0a9
hub search parameters have been cancelled
Changes to container hub search parameters have been cancelled.
2024-06-30 02:24:58 +04:00
lunardunno
40bb2e8ee4
some fix 2024-06-29 06:50:38 +04:00
lunardunno
fe5ffec7c3
Removing aliases for podman
Removing AmneziaVPN aliases for podman-docker when cleaning the server.
2024-06-29 05:47:12 +04:00
lunardunno
d502f1c4d2
correction of comment used 2024-06-29 05:31:01 +04:00
lunardunno
c3e59bbaea
add aliases for podman 2024-06-29 05:23:10 +04:00
lunardunno
5f98d388ef
default value for Check service
the default value for the verification service is set to docker
2024-06-28 08:45:00 +04:00
lunardunno
2fc62cfa24
some changes 2024-06-28 07:18:13 +04:00
lunardunno
b819d87245
docker.io for apt-get 2024-06-27 13:24:02 +04:00
lunardunno
f39b4ecdc4
checking the result of actions, etc.
Change the stub command for check for available packages for Arch Linux.
Checking and changing the locale for correct error handling by the server controller.
Introduction of direct checking of package installation results.
Check which containerization application will be installed.
Checking of docker installation results and service or socket status.
2024-06-27 07:14:56 +04:00
lunardunno
762603f0ad
improving podman compatibility
1) Disabling message: Emulate Docker CLI using podman.
2) Changed short-name-mode operating mode in podman.
3) temporary replacement for the docker service whose activity is being checked
2024-06-26 11:01:11 +04:00
lunardunno
a3601d4dea
enable podman.socket 2024-06-26 06:55:36 +04:00
9 changed files with 68 additions and 14 deletions

View file

@ -409,8 +409,10 @@ ErrorCode ServerController::installDockerWorker(const ServerCredentials &credent
qDebug().noquote() << "ServerController::installDockerWorker" << stdOut;
if (stdOut.contains("lock"))
return ErrorCode::ServerPacketManagerError;
if (stdOut.contains("command not found"))
if (stdOut.contains("sudo:") && stdOut.contains("not found"))
return ErrorCode::ServerDockerFailedError;
if (stdOut.contains("Failed docker status"))
return ErrorCode::ServerDockerStatusNotActive;
return error;
}

View file

@ -58,6 +58,7 @@ namespace amnezia
ServerUserDirectoryNotAccessible = 208,
ServerUserNotAllowedInSudoers = 209,
ServerUserPasswordRequired = 210,
ServerDockerStatusNotActive = 211,
// Ssh connection errors
SshRequestDeniedError = 300,

View file

@ -26,6 +26,7 @@ QString errorString(ErrorCode code) {
case(ErrorCode::ServerUserDirectoryNotAccessible): errorMessage = QObject::tr("The server user's home directory is not accessible"); break;
case(ErrorCode::ServerUserNotAllowedInSudoers): errorMessage = QObject::tr("Action not allowed in sudoers"); break;
case(ErrorCode::ServerUserPasswordRequired): errorMessage = QObject::tr("The user's password is required"); break;
case(ErrorCode::ServerDockerStatusNotActive): errorMessage = QObject::tr("Docker service status is not active"); break;
// Libssh errors
case(ErrorCode::SshRequestDeniedError): errorMessage = QObject::tr("SSH request was denied"); break;

View file

@ -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"

View file

@ -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

View file

@ -1,23 +1,37 @@
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="-Sup"; 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;\
echo $LANG | grep -qE '^(en_US.UTF-8|C.UTF-8|C)$' || export LC_ALL=C;\
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;\
sudo $pm $check_pkgs;\
if [ -n "$(sudo $pm $wh_pkg $docker_pkg 2>/dev/null | grep moby-engine)" ]; \
then echo "Docker is not supported"; exit 1;\
else sudo $pm $silent_inst $docker_pkg;\
fi;\
if [ -n "$(sudo docker --version 2>/dev/null | grep podman)" ]; then docker_pkg="podman-docker"; check_srv="podman.socket podman";\
if [ -n "$(sudo docker --version 2>&1 | grep /etc/containers/nodocker)" ]; then sudo touch /etc/containers/nodocker; fi;\
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"; 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 [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = "Y" ]; then \
if ! command -v apparmor_parser > /dev/null 2>&1; then sudo $pm $check_pkgs; sudo $pm $silent_inst apparmor; 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 docker status"; 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
# To allow autoinstallation of podman-docker, remove ' || [ -n "$(sudo $pm $wh_pkg $docker_pkg 2>/dev/null | grep podman-docker)" ]' and ' || [ -n "$(sudo docker --version 2>&1 | grep podman)" ]'

View file

@ -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;\

View file

@ -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

View file

@ -12,6 +12,12 @@ sudo docker network connect amnezia-dns-net $CONTAINER_NAME
# Create tun device if not exist
sudo docker exec -i $CONTAINER_NAME bash -c 'mkdir -p /dev/net; if [ ! -c /dev/net/tun ]; then mknod /dev/net/tun c 10 200; fi'
# Create service for podman
if [ -n "$(sudo docker --version 2>/dev/null | grep podman)" ]; then \
sudo sh -c "podman generate systemd --new --name $CONTAINER_NAME 2>/dev/null > $DOCKERFILE_FOLDER/container-$CONTAINER_NAME.service";\
sudo mv $DOCKERFILE_FOLDER/container-$CONTAINER_NAME.service /etc/systemd/system/
sudo systemctl daemon-reload && sudo systemctl enable --now container-$CONTAINER_NAME.service;\
fi
# 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"