mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-03-25 09:05:47 +00:00
34 lines
1 KiB
Bash
Executable file
34 lines
1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# bail on errors and unset variables
|
|
set -euo pipefail
|
|
|
|
SWIFT_VERSION=5.1.3
|
|
SWIFT_DIR=swift-$SWIFT_VERSION-RELEASE-ubuntu18.04
|
|
SWIFT_FILENAME=$SWIFT_DIR.tar.gz
|
|
|
|
if [[ $(uname) = "Linux" ]]; then
|
|
if which swift >/dev/null 2>/dev/null && swift --version | grep $SWIFT_VERSION >/dev/null 2>/dev/null; then
|
|
echo "*** swift $SWIFT_VERSION is installed"
|
|
else
|
|
echo "*** installing swift"
|
|
pushd $HOME
|
|
if [[ -e $SWIFT_FILENAME ]]; then
|
|
echo "*** $SWIFT_FILENAME exists, skipping download"
|
|
else
|
|
wget https://swift.org/builds/swift-$SWIFT_VERSION-release/ubuntu1804/swift-$SWIFT_VERSION-RELEASE/$SWIFT_FILENAME
|
|
fi
|
|
if [[ -e $SWIFT_DIR ]]; then
|
|
echo "*** $SWIFT_DIR exists, skipping extraction"
|
|
else
|
|
tar xzf $SWIFT_FILENAME
|
|
fi
|
|
if ! grep $SWIFT_DIR $HOME/.bashrc >/dev/null 2>/dev/null; then
|
|
echo "*** adding $HOME/$SWIFT_DIR/usr/bin to PATH in $HOME/.bashrc"
|
|
echo "export PATH=\"\$HOME/$SWIFT_DIR/usr/bin:\$PATH\"" >> $HOME/.bashrc
|
|
fi
|
|
popd
|
|
fi
|
|
fi
|
|
|
|
echo "*** done"
|