#!/bin/bash set -e SLIVER_GPG_KEY_ID=4449039C if [ "$EUID" -ne 0 ] then echo "Please run as root" exit fi if [ -n "$(command -v yum)" ] then yum -y install gnupg curl gcc gcc-c++ make mingw64-gcc fi if [ -n "$(command -v apt-get)" ] then DEBIAN_FRONTEND=noninteractive apt-get install -yqq \ gpg curl build-essential \ mingw-w64 binutils-mingw-w64 g++-mingw-w64 fi # Curl if ! command -v curl &> /dev/null then echo "curl could not be found" exit 1 fi # Awk if ! command -v awk &> /dev/null then echo "awk could not be found" exit 1 fi # GPG if ! command -v gpg &> /dev/null then echo "gpg could not be found" exit 1 fi cd /root echo "Running from $(pwd)" gpg --import < /etc/systemd/system/sliver.service <<-EOF [Unit] Description=Sliver After=network.target StartLimitIntervalSec=0 [Service] Type=simple Restart=on-failure RestartSec=3 User=root ExecStart=/root/sliver-server daemon [Install] WantedBy=multi-user.target EOF chown root:root /etc/systemd/system/sliver.service chmod 600 /etc/systemd/system/sliver.service systemctl start sliver # Generate local configs echo "Generating operator configs ..." mkdir -p /root/.sliver-client/configs /root/sliver-server operator --name root --lhost localhost --save /root/.sliver-client/configs chown -R root:root /root/.sliver-client/ USER_DIRS=(/home/*) for USER_DIR in "${USER_DIRS[@]}"; do USER=$(basename $USER_DIR) if id -u $USER >/dev/null 2>&1; then mkdir -p $USER_DIR/.sliver-client/configs /root/sliver-server operator --name $USER --lhost localhost --save $USER_DIR/.sliver-client/configs chown -R $USER:"$(id -gn $USER)" $USER_DIR/.sliver-client/ fi done