Skip to content

Commit

Permalink
feat: bluefin-cli modern unix utils
Browse files Browse the repository at this point in the history
feat: make Wolfi have a fake sudo

feat: have linuxbrew in it's own directory by containername
  • Loading branch information
m2Giles committed Feb 5, 2024
1 parent 741c0fa commit 43afd73
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 25 deletions.
3 changes: 1 addition & 2 deletions toolboxes/bluefin-cli/Containerfile.bluefin-cli
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ RUN apk update && \
rm /toolbox-packages

# Patch /usr/bin/entrypoint
RUN sed -i '/missing_packages=0/,/# Workaround for when sudo is missing,/ s/^/#/' /usr/bin/entrypoint && \
sed -i '/elif command -v apt-get/,/# Set SHELL to the install path inside the container/ s/^/#/' /usr/bin/entrypoint && \
RUN sed -i '/missing_packages=0/,/# Set SHELL to the install path inside the container/ s/^/#/' /usr/bin/entrypoint && \
sed -i '/# Set SHELL to the install path inside the container/a touch /.containersetupdone' /usr/bin/entrypoint

# Use and configure bash, retrieve bash-prexec
Expand Down
6 changes: 4 additions & 2 deletions toolboxes/bluefin-cli/files/etc/bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ if [ -z "$BASHRCSOURCED" ]; then
export STARSHIP_CONFIG
eval "$(starship init $SHELL)"

# Enable atuin and ble.sh
# Enable atuin and bash-prexec
source /usr/share/bash-prexec
eval "$(atuin init bash)"
fi

# Enable zoxide
eval "$(zoxide init bash --cmd cd)"
fi

# vim:ts=4:sw=4

Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,41 @@ if test "$(id -u)" -gt "0"; then
export HOMEBREW_REPOSITORY
if test ! -f /etc/linuxbrew.firstrun; then
printf "\nBluefin-CLI First Run Setup\n\n"
printf "Setting up sudo for ${bold}${USER}${normal}...\t\t\t "
printf "Setting up sudo for %s%s%s...\t\t\t " "${bold}" "${USER}" "${normal}"
echo "#${UID} ALL = (root) NOPASSWD:ALL" | su-exec root tee -a /etc/sudoers > /dev/null
printf "${green}[ OK ]${normal}\n"
printf "%s[ OK ]%s\n" "${green}" "${normal}"
fi

if test ! -d /home/linuxbrew/.linuxbrew; then
name=""
test -f /run/.containerenv && . /run/.containerenv
test -f /run/.dockerenv && . /run/.dockerenv
linuxbrew_home="${XDG_DATA_HOME:-$HOME/.local/share}"/bluefin-cli/"${name}"
printf "Setting up Linuxbrew...\t\t\t\t "
if test ! -d "${XDG_DATA_HOME:-$HOME/.local/share}"/bluefin-cli; then
mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}"/bluefin-cli
if test ! -d "${linuxbrew_home}"; then
mkdir -p "${linuxbrew_home}"
if test -d "${XDG_DATA_HOME:-$HOME/.local/share}"/bluefin-cli/.linuxbrew; then
mv "${XDG_DATA_HOME:-$HOME/.local/share}"/bluefin-cli/.linuxbrew "${linuxbrew_home}"/.linuxbrew
fi
fi
if test ! -d /home/linuxbrew; then
su-exec root mkdir -p /home/linuxbrew
fi
su-exec root mount --bind "${XDG_DATA_HOME:-$HOME/.local/share}"/bluefin-cli /home/linuxbrew
su-exec root mount --bind "${linuxbrew_home}" /home/linuxbrew
su-exec root cp -R /home/homebrew/.linuxbrew /home/linuxbrew/
su-exec root chown -R $UID /home/linuxbrew
printf "${green}[ OK ]${normal}\n"
unset linuxbrew_home
printf "%s[ OK ]%s\n" "${green}" "${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
printf "${green}[ OK ]${normal}\n"
if test -x /run/host/usr/bin/ujust; then
su-exec root ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/ujust
fi
printf "%s[ OK ]%s\n" "${green}" "${normal}"
fi

if test ! -f /etc/linuxbrew.firstrun; then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# shellcheck shell=sh disable=SC1091,SC2039,SC2166
# shellcheck shell=sh disable=SC1090,SC1091,SC2039,SC2166,SC2268
# Check for interactive bash and that we haven't already been sourced.
if [ "x${BASH_VERSION-}" != x -a "x${PS1-}" != x -a "x${BASH_COMPLETION_VERSINFO-}" = x ]; then

Expand Down
13 changes: 0 additions & 13 deletions toolboxes/bluefin-cli/files/etc/profile.d/colors.sh

This file was deleted.

19 changes: 19 additions & 0 deletions toolboxes/bluefin-cli/files/etc/profile.d/modern-unix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Eza for ls
alias ll='eza -l --icons=auto --group-directories-first' 2>/dev/null
alias l.='eza -d .*' 2>/dev/null
alias ls='eza' 2>/dev/null
alias l1='eza -1'

# Ripgrep for grep
alias grep='rg' 2>/dev/null
alias egrep='rg' 2>/dev/null
alias fgrep='rg -F' 2>/dev/null
alias xzgrep='rg -z' 2>/dev/null
alias xzegrep='rg -z' 2>/dev/null
alias xzfgrep='rg -z -F' 2>/dev/null

# Zoxide is handling cd
alias cd='cd' 2>/dev/null

# Fd for find
alias find='fd' 2>/dev/null
4 changes: 4 additions & 0 deletions toolboxes/bluefin-cli/packages.bluefin-cli
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ atuin
brew
gawk
eza
fd
fzf
ripgrep
sed
starship
sudo-rs
zoxide
7 changes: 7 additions & 0 deletions toolboxes/wolfi-toolbox/Containerfile.wolfi
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ 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

0 comments on commit 43afd73

Please sign in to comment.