mirror of
https://github.com/Zerodya/dockeraise.git
synced 2026-06-24 02:00:01 +07:00
Add checks for apt and user ID
Now checks if machine is Debian-based (apt exists), and if another user with the same ID as the Docker user already exists.
This commit is contained in:
+19
-4
@@ -16,6 +16,12 @@ if [[ "$(command -v docker)" -ne "" ]]; then
|
|||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if machine is Debian-based
|
||||||
|
if [[ "$(command -v apt)" == "" ]]; then
|
||||||
|
echo -e "${err} This script only works on Debian-based machines, sorry!"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
echo -e "${info} Updating repositories..."
|
echo -e "${info} Updating repositories..."
|
||||||
apt-get update &> /dev/null
|
apt-get update &> /dev/null
|
||||||
@@ -49,7 +55,7 @@ while true; do
|
|||||||
read -p "[?] Do you want to install Docker-Compose? [y/n] " yn
|
read -p "[?] Do you want to install Docker-Compose? [y/n] " yn
|
||||||
case $yn in
|
case $yn in
|
||||||
[Yy]* ) echo -e "${info} Installing Docker-Compose (this might take a while)...";
|
[Yy]* ) echo -e "${info} Installing Docker-Compose (this might take a while)...";
|
||||||
apt-get install -y docker-compose &> /dev/null ;
|
apt-get install -y docker-compose &> /dev/null;
|
||||||
echo -e "${msg} Docker Compose successfully installed:" $(docker-compose --version);
|
echo -e "${msg} Docker Compose successfully installed:" $(docker-compose --version);
|
||||||
break;;
|
break;;
|
||||||
[Nn]* ) break;;
|
[Nn]* ) break;;
|
||||||
@@ -61,8 +67,16 @@ done
|
|||||||
while true; do
|
while true; do
|
||||||
read -p "[?] Do you want to create a Docker user? [y/n] " yn
|
read -p "[?] Do you want to create a Docker user? [y/n] " yn
|
||||||
case $yn in
|
case $yn in
|
||||||
[Yy]* ) read -p "Please choose an id for the new user/group: " id;
|
[Yy]* ) while :; do
|
||||||
/usr/sbin/groupadd -g $id dockeruser && /usr/sbin/useradd dockeruser -u $id -g $id -m -s /bin/bash && echo "${add} Docker user created:" && id dockeruser;
|
read -p "Please choose an ID for the new user/group: " id;
|
||||||
|
if [[ id "$id" &>/dev/null ]]; then
|
||||||
|
echo -e "${err} An user with the same ID already exists.";
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
/usr/sbin/groupadd -g $id dockeruser && /usr/sbin/useradd dockeruser -u $id -g $id -m -s /bin/bash && echo -e "${add} Docker user created:" && id dockeruser;
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
done
|
||||||
break;;
|
break;;
|
||||||
[Nn]* ) break;;
|
[Nn]* ) break;;
|
||||||
* ) ;;
|
* ) ;;
|
||||||
@@ -70,7 +84,8 @@ while true; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Enable Docker service at startup
|
# Enable Docker service at startup
|
||||||
|
echo -e "${info} Starting Docker services..."
|
||||||
systemctl start docker.service docker.socket containerd && systemctl enable docker.service docker.socket containerd &> /dev/null
|
systemctl start docker.service docker.socket containerd && systemctl enable docker.service docker.socket containerd &> /dev/null
|
||||||
echo -e "${msg} Docker service started and enabled."
|
echo -e "${msg} Docker services started and enabled."
|
||||||
|
|
||||||
echo -e "${info} Process completed. Run '\033[0;36msystemctl status docker\033[m' to check Docker's status."
|
echo -e "${info} Process completed. Run '\033[0;36msystemctl status docker\033[m' to check Docker's status."
|
||||||
|
|||||||
Reference in New Issue
Block a user