create uncloud Linux group in install script

This commit is contained in:
Pavel Sviderski
2024-09-20 16:54:02 +10:00
parent 6856a77b56
commit a980cb7941
+21
View File
@@ -6,6 +6,8 @@ INSTALL_BIN_DIR=${INSTALL_BIN_DIR:-/usr/local/bin}
INSTALL_SYSTEMD_DIR=${INSTALL_SYSTEMD_DIR:-/etc/systemd/system} INSTALL_SYSTEMD_DIR=${INSTALL_SYSTEMD_DIR:-/etc/systemd/system}
UNCLOUD_GITHUB_URL="https://github.com/psviderski/uncloud" UNCLOUD_GITHUB_URL="https://github.com/psviderski/uncloud"
UNCLOUD_VERSION=${UNCLOUD_VERSION:-latest} UNCLOUD_VERSION=${UNCLOUD_VERSION:-latest}
UNCLOUD_GROUP="uncloud"
UNCLOUD_GROUP_ADD_USER=${UNCLOUD_GROUP_ADD_USER:-}
log() { log() {
echo -e "\033[1;32m$1\033[0m" >&2 echo -e "\033[1;32m$1\033[0m" >&2
@@ -50,6 +52,24 @@ install_docker() {
log "✓ Docker installed successfully." log "✓ Docker installed successfully."
} }
create_uncloud_group() {
if getent group "${UNCLOUD_GROUP}" > /dev/null; then
log "✓ Linux group 'uncloud' already exists."
else
if ! groupadd --system "${UNCLOUD_GROUP}"; then
error "Failed to create Linux group 'uncloud'."
fi
log "✓ Linux group 'uncloud' created."
fi
if [ -n "${UNCLOUD_GROUP_ADD_USER}" ]; then
if ! gpasswd --add "${UNCLOUD_GROUP_ADD_USER}" "${UNCLOUD_GROUP}" > /dev/null; then
error "Failed to add user '${UNCLOUD_GROUP_ADD_USER}' to group '${UNCLOUD_GROUP}'."
fi
log "✓ Linux user '${UNCLOUD_GROUP_ADD_USER}' added to group '${UNCLOUD_GROUP}'."
fi
}
install_uncloud_binaries() { install_uncloud_binaries() {
local arch local arch
local file_arch local file_arch
@@ -152,6 +172,7 @@ fi
verify_system verify_system
install_docker install_docker
create_uncloud_group
install_uncloud_binaries install_uncloud_binaries
install_uncloud_systemd install_uncloud_systemd