Skip to content

Commit

Permalink
Merge pull request #96 from ublue-os/wolfi-sudo
Browse files Browse the repository at this point in the history
feat: switch wolfi to sudo
  • Loading branch information
castrojo authored May 17, 2024
2 parents 0a8f0fa + f7f468d commit caa9abb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ if test "$(id -u)" -gt "0"; then
blue=$(printf '\033[38;5;32m')
bold=$(printf '\033[1m')
normal=$(printf '\033[0m')
if test ! -f /etc/linuxbrew.firstrun; then
printf "\nBluefin-CLI First Run Setup\n\n"
printf "Setting up sudo for %s%s%s%s...\t\t\t " "$bold" "$blue" "$USER" "$normal"
echo "#$(id -u) ALL = (root) NOPASSWD:ALL" | su-exec root tee -a /etc/sudoers > /dev/null
printf "%s[ OK ]%s\n" "${blue}" "${normal}"
fi

if test ! -d /home/linuxbrew/.linuxbrew; then
name="$(hostname -s)"
Expand All @@ -21,27 +15,27 @@ if test "$(id -u)" -gt "0"; then
fi
fi
if test ! -d /home/linuxbrew; then
su-exec root mkdir -p /home/linuxbrew
sudo mkdir -p /home/linuxbrew
fi
su-exec root mount --bind "${linuxbrew_home}" /home/linuxbrew
su-exec root cp -R /home/homebrew/.linuxbrew /home/linuxbrew/
su-exec root chown -R "$(id -u)" /home/linuxbrew
sudo mount --bind "${linuxbrew_home}" /home/linuxbrew
sudo cp -R /home/homebrew/.linuxbrew /home/linuxbrew/
sudo chown -R "$(id -u)" /home/linuxbrew
unset linuxbrew_home
printf "%s[ OK ]%s\n" "${blue}" "${normal}"
fi

if test ! -d /usr/local/share/bash-completion/completions; then
printf "Setting up Tab-Completions...\t\t\t "
su-exec root mkdir -p /usr/local/share/bash-completion
su-exec root mount --bind /run/host/usr/share/bash-completion /usr/local/share/bash-completion
sudo mkdir -p /usr/local/share/bash-completion
sudo mount --bind /run/host/usr/share/bash-completion /usr/local/share/bash-completion
if test -x /run/host/usr/bin/ujust; then
su-exec root ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/ujust
sudo ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/ujust
fi
printf "%s[ OK ]%s\n" "${blue}" "${normal}"
fi

if test ! -f /etc/linuxbrew.firstrun; then
su-exec root touch /etc/linuxbrew.firstrun
sudo touch /etc/linuxbrew.firstrun
printf "\nBluefin-CLI first run complete!\n\n"
fi
fi
9 changes: 2 additions & 7 deletions toolboxes/wolfi-toolbox/Containerfile.wolfi
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,5 @@ RUN mkdir -p /usr/local/bin && \
# Change root shell to BASH
RUN sed -i -e '/^root/s/\/bin\/ash/\/bin\/bash/' /etc/passwd

# Setup su-exec and fake sudo
RUN [ -e /sbin/su-exec ] && \
chmod u+s /sbin/su-exec && \
[ ! -e /usr/bin/sudo ] && \
printf "%s\n%s" '#!/bin/sh' '/sbin/su-exec root "$@"' > /usr/bin/sudo && \
chmod +x /usr/bin/sudo && \
rm -rf /tmp/*
# Delete nonroot user
RUN userdel nonroot && rm -rf /home/nonroot
5 changes: 4 additions & 1 deletion toolboxes/wolfi-toolbox/packages.wolfi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bash
bc
bzip2
coreutils
curl
Expand All @@ -11,7 +12,9 @@ gpg
iproute2
iputils
keyutils
less
libcap
libcap-utils
libsm
libx11
libxau
Expand All @@ -33,7 +36,7 @@ posix-libc-utils
procps
rsync
shadow
su-exec
sudo
tcpdump
tree
tzdata
Expand Down

0 comments on commit caa9abb

Please sign in to comment.