made init hooks script idemptent
This commit is contained in:
@@ -34,14 +34,18 @@ EOF
|
||||
export RUSTUP_HOME=/opt/rustup
|
||||
export CARGO_HOME=/opt/cargo
|
||||
|
||||
echo "Installing rustup..."
|
||||
if [[ ! -x /opt/cargo/bin/rustup ]]; then
|
||||
echo "Installing rustup..."
|
||||
|
||||
curl \
|
||||
--proto '=https' \
|
||||
--tlsv1.2 \
|
||||
-sSf \
|
||||
https://sh.rustup.rs \
|
||||
| sh -s -- -y --no-modify-path
|
||||
curl \
|
||||
--proto '=https' \
|
||||
--tlsv1.2 \
|
||||
-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,13 +62,27 @@ echo "Installing rustup Fish completion..."
|
||||
# -----------------------------------------------------------------------------
|
||||
# Aseprite
|
||||
# -----------------------------------------------------------------------------
|
||||
echo "Building Aseprite..."
|
||||
git clone --recursive https://github.com/aseprite/aseprite.git /opt/aseprite
|
||||
cd /opt/aseprite
|
||||
./build.sh --auto --norun
|
||||
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
|
||||
|
||||
echo "Creating Aseprite desktop entry..."
|
||||
cat > /opt/aseprite/aseprite.desktop <<'EOF'
|
||||
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'
|
||||
[Desktop Entry]
|
||||
Name=Aseprite
|
||||
Comment=Animated sprite editor
|
||||
@@ -74,9 +92,16 @@ Terminal=false
|
||||
Type=Application
|
||||
Categories=Graphics;2DGraphics;
|
||||
EOF
|
||||
fi
|
||||
|
||||
echo "Exporting Aseprite desktop entry..."
|
||||
sudo -u "$DEV_USER" env HOME="$DEV_HOME" distrobox-export --app /opt/aseprite/aseprite.desktop
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user