mirror of
https://github.com/elisspace/rtinst.git
synced 2026-08-29 15:44:06 +00:00
66 lines
1.9 KiB
Bash
Executable File
66 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
######################################################################
|
|
#
|
|
# Copyright (c) 2015 arakasi72 (https://github.com/arakasi72)
|
|
#
|
|
# --> Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
|
|
#
|
|
######################################################################
|
|
|
|
PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/bin:/sbin
|
|
|
|
if [ "$(id -u)" != "0" ]; then
|
|
echo "Must be run as root, directly or with sudo"
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -d /etc/rtinst ]; then
|
|
git clone https://github.com/arakasi72/rtinst.git /etc/rtinst
|
|
fi
|
|
|
|
cd /etc/rtinst
|
|
|
|
branch=$(basename "$(git symbolic-ref -q HEAD)")
|
|
|
|
# if branch is empty then it is a tag
|
|
if [ -z $branch ]; then
|
|
branch=$(git describe --tags --exact-match)
|
|
if [ ${branch:0:1} = v ]; then
|
|
latest=$(basename "$(git ls-remote --tags https://github.com/arakasi72/rtinst.git | grep -o 'refs/tags/v.*' | sort -V | tail -1)")
|
|
if [ $branch = $latest ]; then
|
|
echo "Already using the latest release: $branch"
|
|
exit
|
|
fi
|
|
# update to latest release
|
|
echo "rtinst updating from $branch to $latest"
|
|
cd
|
|
rm -fr /etc/rtinst
|
|
git clone -q https://github.com/arakasi72/rtinst.git /etc/rtinst
|
|
cd /etc/rtinst
|
|
git checkout -q $latest
|
|
branch=$(git describe --tags --exact-match)
|
|
echo "rtinst $branch installed"
|
|
cd
|
|
ln -sf /etc/rtinst/scripts/* /usr/local/bin
|
|
ln -sf /etc/rtinst/rtsetup /usr/local/bin
|
|
exit
|
|
else
|
|
echo "$branch is not a branch, or a numbered release"
|
|
echo "Run rtsetup if you want to switch to another build"
|
|
exit
|
|
fi
|
|
fi
|
|
|
|
if [ $(git ls-remote --heads https://github.com/arakasi72/rtinst.git $branch | wc -l) -eq 0 ]; then
|
|
echo "$branch no longer appears to exist"
|
|
echo "run rtsetup to reset branch"
|
|
else
|
|
git fetch --all
|
|
git reset --hard origin/$branch > /dev/null 2>&1
|
|
git pull origin $branch
|
|
|
|
ln -sf /etc/rtinst/scripts/* /usr/local/bin
|
|
ln -sf /etc/rtinst/rtsetup /usr/local/bin
|
|
fi
|