made init hooks script idemptent

This commit is contained in:
2026-09-15 06:24:20 +02:00
parent 90e2952211
commit 596b5873e6
+45 -4
View File
@@ -34,6 +34,7 @@ EOF
export RUSTUP_HOME=/opt/rustup
export CARGO_HOME=/opt/cargo
if [[ ! -x /opt/cargo/bin/rustup ]]; then
echo "Installing rustup..."
curl \
@@ -42,6 +43,9 @@ curl \
-sSf \
https://sh.rustup.rs \
| sh -s -- -y --no-modify-path
else
echo "rustup is already installed."
fi
# Rust toolchain
echo "Installing stable Rust toolchain..."
@@ -58,10 +62,24 @@ echo "Installing rustup Fish completion..."
# -----------------------------------------------------------------------------
# Aseprite
# -----------------------------------------------------------------------------
echo "Building Aseprite..."
if [[ -f /opt/aseprite/aseprite.desktop ]]; then
echo "Aseprite desktop entry already exists; skipping installation."
else
if [[ ! -d /opt/aseprite ]]; then
echo "Cloning Aseprite..."
git clone --recursive https://github.com/aseprite/aseprite.git /opt/aseprite
else
echo "Aseprite source already exists."
fi
cd /opt/aseprite
if [[ ! -x /opt/aseprite/build/bin/aseprite ]]; then
git submodule update --init --recursive
echo "Building Aseprite..."
./build.sh --auto --norun
else
echo "Aseprite is already built."
fi
echo "Creating Aseprite desktop entry..."
cat > /opt/aseprite/aseprite.desktop <<'EOF'
@@ -74,9 +92,16 @@ Terminal=false
Type=Application
Categories=Graphics;2DGraphics;
EOF
fi
if sudo -u "$DEV_USER" env HOME="$DEV_HOME" distrobox-export --list-apps 2>/dev/null |
grep -Fq "aseprite"
then
echo "Aseprite desktop entry is already exported."
else
echo "Exporting Aseprite desktop entry..."
sudo -u "$DEV_USER" env HOME="$DEV_HOME" distrobox-export --app /opt/aseprite/aseprite.desktop
fi
# -----------------------------------------------------------------------------
# Export development tools to the host
@@ -87,15 +112,31 @@ echo "Exporting development tools..."
export_bin() {
local binary="$1"
if command -v "$binary" >/dev/null 2>&1; then
if ! command -v "$binary" >/dev/null 2>&1; then
echo " warning: $binary not found"
elif sudo -u "$DEV_USER" env HOME="$DEV_HOME" \
distrobox-export \
--list-binaries \
--export-path "$DEV_HOME/.local/bin" 2>/dev/null |
awk -F'|' -v binary="$binary" '
{
name = $1
gsub(/^[[:space:]]+|[[:space:]]+$/, "", name)
if (name == binary) {
found = 1
}
}
END { exit !found }
'
then
echo " $binary is already exported."
else
echo " exporting $binary"
sudo -u "$DEV_USER" \
env HOME="$DEV_HOME" \
distrobox-export \
--bin "$(command -v "$binary")" \
--export-path "$DEV_HOME/.local/bin"
else
echo " warning: $binary not found"
fi
}