2021-06-15 10:26:26 +02:00
|
|
|
#!/bin/bash
|
2021-04-27 13:03:56 +02:00
|
|
|
|
|
|
|
# variables
|
2021-09-23 15:52:55 +02:00
|
|
|
GITHUB_REPO=htrefil/rkvm
|
|
|
|
VERSION=${VERSION:-$(curl -s https://api.github.com/repos/${GITHUB_REPO}/releases/latest | jq -r .tag_name | sed 's|^null$|trunk|')} # or VERSION=trunk
|
2021-04-27 13:03:56 +02:00
|
|
|
BUILD=${BUILD:-1}
|
|
|
|
|
|
|
|
TAG=gwh
|
|
|
|
TMP=/tmp/$TAG
|
|
|
|
CWD=$(pwd)
|
|
|
|
|
|
|
|
PRGNAM=$(basename $CWD)
|
|
|
|
PKG=$TMP/pkg-$PRGNAM
|
|
|
|
OUTPUT=${OUTPUT:-/tmp}
|
|
|
|
|
|
|
|
ARCH=${ARCH:-$(uname -m)}
|
|
|
|
|
|
|
|
REPOSITORY=${REPOSITORY:-/home/installs/SlackBuilds/repositories/$PRGNAM}
|
|
|
|
PREFIX=${PREFIX:-/usr}
|
|
|
|
|
|
|
|
# nettoyage préalable
|
|
|
|
rm -fr $PKG $TMP/$PRGNAM
|
|
|
|
|
|
|
|
mkdir -p $PKG
|
|
|
|
|
|
|
|
# mise en place
|
|
|
|
cd $TMP
|
2021-09-23 15:52:55 +02:00
|
|
|
[ ! -e $REPOSITORY ] && git clone https://github.com/${GITHUB_REPO}.git $REPOSITORY
|
2021-06-15 10:59:49 +02:00
|
|
|
cd $REPOSITORY
|
|
|
|
git pull --all
|
2021-04-27 13:03:56 +02:00
|
|
|
|
|
|
|
cp -R $REPOSITORY $TMP/
|
|
|
|
cd $TMP/$PRGNAM
|
2021-06-15 15:15:18 +02:00
|
|
|
[ "x$VERSION" == "xtrunk" ] && VERSION="git_$(git log -1 --format=%h_%ad --date=format:%Y.%m.%d)" || git checkout $VERSION
|
2021-04-27 13:03:56 +02:00
|
|
|
|
|
|
|
cargo build --release
|
|
|
|
|
|
|
|
mkdir -p $PKG$PREFIX/bin
|
|
|
|
find target/release/ -type f -executable -maxdepth 1 -exec cp {} $PKG$PREFIX/bin/ \;
|
|
|
|
chmod 755 $PKG$PREFIX/bin/*
|
2021-04-27 13:59:16 +02:00
|
|
|
(cd $PKG$PREFIX/bin/
|
|
|
|
for i in *; do
|
|
|
|
mv $i rkvm-$i;
|
|
|
|
done
|
|
|
|
)
|
2021-04-27 13:03:56 +02:00
|
|
|
|
|
|
|
# move doc/ to the appropriate location
|
|
|
|
mkdir -p $PKG$PREFIX/doc/$PRGNAM
|
|
|
|
cp -R example/ LICENSE *.md $PKG$PREFIX/doc/$PRGNAM
|
|
|
|
|
2021-04-27 13:59:16 +02:00
|
|
|
cat <<EOF > $PKG$PREFIX/doc/$PRGNAM/setup-keys.sh
|
|
|
|
#!/bin/bash
|
|
|
|
$PREFIX/bin/rkvm-certificate-gen /etc/rkvm/identity.p12.new /etc/rkvm/certificate.pem.new /etc/rkvm/key.pem.new -i \$(hostname -I | cut -d\\ -f1)
|
|
|
|
EOF
|
|
|
|
chmod +x $PKG$PREFIX/doc/$PRGNAM/setup-keys.sh
|
|
|
|
|
|
|
|
mkdir -p $PKG/etc/rc.d
|
|
|
|
cat <<EOF > $PKG/etc/rc.d/rc.rkvm-server
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
start() {
|
|
|
|
echo "Starting rkvm server..."
|
|
|
|
|
|
|
|
/usr/bin/rkvm-server /etc/rkvm/server.toml &
|
|
|
|
|
|
|
|
[ $? -ne 0 ] && echo "Could not start rkvm-server."
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
killall /usr/bin/rkvm-server
|
|
|
|
}
|
|
|
|
|
|
|
|
case \$1 in
|
|
|
|
start )
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop )
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
restart )
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
echo "Unrecognized command: \$1"
|
|
|
|
echo "Try one of the following: (start|stop|restart)"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
EOF
|
|
|
|
cat <<EOF > $PKG/etc/rc.d/rc.rkvm-client
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
start() {
|
|
|
|
echo "Starting rkvm client..."
|
|
|
|
|
|
|
|
/usr/bin/rkvm-client /etc/rkvm/client.toml &
|
|
|
|
|
|
|
|
[ $? -ne 0 ] && echo "Could not start rkvm-client."
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
killall /usr/bin/rkvm-client
|
|
|
|
}
|
|
|
|
|
|
|
|
case \$1 in
|
|
|
|
start )
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop )
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
restart )
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
echo "Unrecognized command: \$1"
|
|
|
|
echo "Try one of the following: (start|stop|restart)"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
EOF
|
|
|
|
|
|
|
|
mkdir -p $PKG/etc/rkvm
|
|
|
|
cat <<EOF > $PKG/etc/rkvm/server.toml.new
|
|
|
|
listen-address = "0.0.0.0:5258"
|
|
|
|
# Switch to next client by pressing the right alt key.
|
|
|
|
switch-keys = ["RightAlt"]
|
|
|
|
identity-path = "/etc/rkvm/identity.p12"
|
|
|
|
# Leave unset if no password is set.
|
|
|
|
#identity-password = "123456789"
|
|
|
|
EOF
|
|
|
|
cat <<EOF > $PKG/etc/rkvm/client.toml.new
|
|
|
|
server = "$(hostname -I | cut -d\ -f1):5258"
|
|
|
|
certificate-path = "/etc/rkvm/certificate.pem"
|
|
|
|
EOF
|
|
|
|
|
2021-04-27 13:03:56 +02:00
|
|
|
# correction
|
|
|
|
cd $PKG
|
|
|
|
chown -R root:root *
|
|
|
|
|
|
|
|
find $PKG$PREFIX/man -type f -not -name \*.gz -exec gzip -9 {} \;
|
|
|
|
|
|
|
|
# embaumement
|
|
|
|
mkdir -p $PKG/install
|
|
|
|
|
|
|
|
cat <<EOF > $PKG/install/slack-desc
|
|
|
|
# HOW TO EDIT THIS FILE:
|
|
|
|
# The "handy ruler" below makes it easier to edit a package description. Line
|
|
|
|
# up the first '|' above the ':' following the base package name, and the '|'
|
|
|
|
# on the right side marks the last column you can put a character in. You must
|
|
|
|
# make exactly 11 lines for the formatting to be correct. It's also
|
|
|
|
# customary to leave one space after the ':'.
|
|
|
|
|
|
|
|
|-----handy-ruler------------------------------------------------------|
|
|
|
|
$PRGNAM: $PRGNAM ( Virtual KVM switch for Linux machines )
|
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM: rkvm is a tool for sharing keyboard and mouse across multiple Linux
|
|
|
|
$PRGNAM: and Windows machines. It is based on a client/server architecture,
|
|
|
|
$PRGNAM: where server is the machine controlling mouse and keyboard and relays
|
|
|
|
$PRGNAM: events (mouse move, key presses, ...) to clients.
|
|
|
|
$PRGNAM: Switching between different clients is done by a configurable keyboard
|
|
|
|
$PRGNAM: shortcut.
|
|
|
|
$PRGNAM:
|
2021-04-27 13:59:16 +02:00
|
|
|
$PRGNAM: (use $PREFIX/doc/$PRGNAM/gen-keys.sh)
|
2021-09-23 15:52:55 +02:00
|
|
|
$PRGNAM: https://github.com/${GITHUB_REPO}
|
2021-04-27 13:03:56 +02:00
|
|
|
EOF
|
|
|
|
|
|
|
|
# empaquetage
|
|
|
|
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la
|
|
|
|
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz
|