-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Plugins - Add self-hosted CSM-Sentinel plugin
- Loading branch information
1 parent
501a8b2
commit 30a36f9
Showing
4 changed files
with
335 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/bin/bash | ||
|
||
# Author: coincashew.eth | coincashew.com | ||
# License: GNU GPL | ||
# Source: https://github.com/coincashew/ethpillar | ||
# Description: csm-sentinel helper script | ||
# | ||
# Made for home and solo stakers 🏠🥩 | ||
|
||
# Base directory with scripts | ||
BASE_DIR=$HOME/git/ethpillar | ||
|
||
# Variables | ||
#GITHUB_URL=https://api.github.com/repos/skhomuti/csm-sentinel/releases/latest | ||
#GITHUB_RELEASE_NODES=https://github.com/skhomuti/csm-sentinel/releases | ||
DESCRIPTION="CSM Sentinel is a telegram bot that sends you notifications for your CSM Node Operator events. Self-hosted. Uses docker." | ||
DOCUMENTATION="https://github.com/skhomuti/csm-sentinel" | ||
SOURCE_CODE="https://github.com/skhomuti/csm-sentinel" | ||
APP_NAME="csm-sentinel" | ||
PLUGIN_NAME="CSM Sentinel Plugin" | ||
PLUGIN_SOURCE_PATH="$BASE_DIR/plugins/sentinel" | ||
PLUGIN_INSTALL_PATH="/opt/ethpillar/plugin-sentinel" | ||
|
||
#Asks to update | ||
function upgrade(){ | ||
if whiptail --title "Update $PLUGIN_NAME" --yesno "Reminder: Always read the release notes for breaking changes: $SOURCE_CODE\n\nDo you want to update?" 10 78; then | ||
cd $PLUGIN_INSTALL_PATH/$APP_NAME | ||
sudo git pull | ||
sudo docker stop $APP_NAME | ||
sudo docker build -t csm-sentinel . | ||
__start | ||
fi | ||
} | ||
|
||
# Installs latest release | ||
function install(){ | ||
exec sudo $PLUGIN_SOURCE_PATH/sentinel-installer.sh | ||
} | ||
|
||
# Starts the docker container | ||
function __start(){ | ||
cd $PLUGIN_INSTALL_PATH/$APP_NAME | ||
if docker ps -aq --filter=name=$APP_NAME > /dev/null 2>&1; then | ||
sudo docker rm -f $APP_NAME | ||
fi | ||
sudo docker run --net=host -d --env-file=.env --name csm-sentinel -v csm-sentinel-persistent:/app/.storage csm-sentinel | ||
} | ||
|
||
# Uninstall | ||
function removeAll() { | ||
if whiptail --title "Uninstall $APP_NAME" --defaultno --yesno "Are you sure you want to remove $APP_NAME" 9 78; then | ||
sudo docker stop "$APP_NAME" | ||
sudo docker rm -f $APP_NAME | ||
sudo docker rmi -f "$APP_NAME" | ||
sudo docker volume rm csm-sentinel-persistent | ||
sudo rm -rf "$PLUGIN_INSTALL_PATH" | ||
whiptail --title "Uninstall finished" --msgbox "You have uninstalled $APP_NAME." 8 78 | ||
fi | ||
} | ||
|
||
# Displays usage info | ||
function usage() { | ||
cat << EOF | ||
Usage: $(basename "$0") [-i] [-u] [-r] [-s] | ||
$APP_NAME Helper Script | ||
Options) | ||
-i Install $APP_NAME | ||
-u Upgrade $APP_NAME | ||
-r Remove $APP_NAME | ||
-s Start $APP_NAME | ||
-h Display help | ||
About $APP_NAME) | ||
- $DESCRIPTION | ||
- Source code: $SOURCE_CODE | ||
- Documentation: $DOCUMENTATION | ||
EOF | ||
} | ||
|
||
# Process command line options | ||
while getopts :iurhs opt; do | ||
case ${opt} in | ||
i ) install ;; | ||
u ) upgrade ;; | ||
r ) removeAll ;; | ||
s ) __start ;; | ||
h) | ||
usage | ||
exit 0 | ||
;; | ||
\?) | ||
echo "Invalid option: -${OPTARG}" >&2 | ||
usage | ||
exit 1 | ||
;; | ||
:) | ||
echo "Option -${OPTARG} requires an argument." >&2 | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
#!/bin/bash | ||
|
||
# Author: coincashew.eth | coincashew.com | ||
# License: GNU GPL | ||
# Source: https://github.com/coincashew/ethpillar | ||
# Description: csm-sentinel installer script | ||
# | ||
# Made for home and solo stakers 🏠🥩 | ||
|
||
set -e | ||
set -x | ||
|
||
setWhiptailColors(){ | ||
export NEWT_COLORS='root=,black | ||
border=green,black | ||
title=green,black | ||
roottext=red,black | ||
window=red,black | ||
textbox=white,black | ||
button=black,green | ||
compactbutton=white,black | ||
listbox=white,black | ||
actlistbox=black,white | ||
actsellistbox=black,green | ||
checkbox=green,black | ||
actcheckbox=black,green' | ||
} | ||
setWhiptailColors | ||
|
||
MSG_ABOUT="About: CSM Sentinel is a telegram bot that sends you notifications for your CSM Node Operator events. | ||
\nMaintainer: This bot was developed and is maintained by @skhomuti, a member of the Lido Protocol community, to simplify the process of subscribing to the important events for CSM. | ||
\nLocally ran instance: This bot will run on your node, self-hosted for your own improved reliability and privacy. | ||
\nSource Code: https://github.com/skhomuti/csm-sentinel | ||
\nContinue to install?" | ||
|
||
# Intro screen | ||
if ! whiptail --title "CSM Sentinel: Running your own instance" --yesno "$MSG_ABOUT" 20 78; then exit; fi | ||
|
||
# Get network | ||
_NETWORK=$(whiptail --title "Set Network" --menu \ | ||
"For which network are you running CSM Sentinel?" 10 78 2 \ | ||
"mainnet" "ethereum" \ | ||
"holesky" "testnet" \ | ||
3>&1 1>&2 2>&3) | ||
|
||
MSG_TOKEN="First, you need to create a bot on Telegram. | ||
\nTo create a bot, initiate a conversation with @BotFather (https://t.me/botfather), select the 'New Bot' option, and follow the prompts to set up your bot's name, username, and initial settings. | ||
\nEnter the token you received from the BotFather. | ||
\nExample: 270485614:AAHfiqksKZ8WmR2zSjiQ7_v4TMAKdiHm9T0" | ||
|
||
# Get token | ||
while true; do | ||
_TOKEN=$(whiptail --title "Set Token from BotFather" --inputbox "$MSG_TOKEN" 17 78 --ok-button "Submit" 3>&1 1>&2 2>&3) | ||
if [ -z "$_TOKEN" ]; then exit; fi #pressed cancel | ||
if [[ "${_TOKEN}" =~ [0-9]+:.* ]]; then | ||
break | ||
else | ||
whiptail --title "Error" --msgbox "Invalid TOKEN. Try again." 8 78 | ||
fi | ||
done | ||
|
||
MSG_WEB3_SOCKET_PROVIDER="The websocket provider for your node. | ||
\nPreferably, use your own local execution client node e.g. you already have for CSM validators. | ||
\nDefault example: ws://127.0.0.1:8545" | ||
|
||
# Get token | ||
_WEB3_SOCKET_PROVIDER=$(whiptail --title "Set WEB3_SOCKET_PROVIDER" --inputbox "$MSG_WEB3_SOCKET_PROVIDER" 15 78 "ws://127.0.0.1:8545" --ok-button "Submit" 3>&1 1>&2 2>&3) | ||
if [ -z "$_WEB3_SOCKET_PROVIDER" ]; then exit; fi #pressed cancel | ||
|
||
# Install packages | ||
apt-get update | ||
apt-get upgrade -y | ||
|
||
install_docker() { | ||
# Install Docker | ||
sudo apt-get install --yes docker.io | ||
# Verify that we can at least get version output | ||
if ! docker --version; then | ||
echo "ERROR: Is Docker installed?" | ||
exit 1 | ||
fi | ||
} | ||
|
||
if ! command -v docker &> /dev/null; then | ||
install_docker | ||
fi | ||
|
||
# Setup files | ||
mkdir -p /opt/ethpillar/plugin-sentinel | ||
cd /opt/ethpillar/plugin-sentinel | ||
if [[ ! -d /opt/ethpillar/plugin-sentinel/csm-sentinel ]]; then | ||
git clone https://github.com/skhomuti/csm-sentinel | ||
cd csm-sentinel | ||
else | ||
cd csm-sentinel && git pull | ||
fi | ||
|
||
# Build image | ||
docker build -t csm-sentinel . | ||
docker volume create csm-sentinel-persistent | ||
|
||
# Create env file | ||
case $_NETWORK in | ||
mainnet) | ||
cat << EOF > /opt/ethpillar/plugin-sentinel/csm-sentinel/.env | ||
FILESTORAGE_PATH=.storage | ||
TOKEN=${_TOKEN} | ||
WEB3_SOCKET_PROVIDER=${_WEB3_SOCKET_PROVIDER} | ||
CSM_ADDRESS=0xdA7dE2ECdDfccC6c3AF10108Db212ACBBf9EA83F | ||
ACCOUNTING_ADDRESS=0x4d72BFF1BeaC69925F8Bd12526a39BAAb069e5Da | ||
FEE_DISTRIBUTOR_ADDRESS=0xD99CC66fEC647E68294C6477B40fC7E0F6F618D0 | ||
VEBO_ADDRESS=0x0De4Ea0184c2ad0BacA7183356Aea5B8d5Bf5c6e | ||
CSM_STAKING_MODULE_ID=3 | ||
ETHERSCAN_URL=https://etherscan.io | ||
BEACONCHAIN_URL=https://beaconcha.in | ||
CSM_UI_URL=https://csm.lido.fi/?ref=ethpillar | ||
EOF | ||
;; | ||
holesky) | ||
cat << EOF > /opt/ethpillar/plugin-sentinel/csm-sentinel/.env | ||
FILESTORAGE_PATH=.storage | ||
TOKEN=${_TOKEN} | ||
WEB3_SOCKET_PROVIDER=${_WEB3_SOCKET_PROVIDER} | ||
CSM_ADDRESS=0x4562c3e63c2e586cD1651B958C22F88135aCAd4f | ||
ACCOUNTING_ADDRESS=0xc093e53e8F4b55A223c18A2Da6fA00e60DD5EFE1 | ||
FEE_DISTRIBUTOR_ADDRESS=0xD7ba648C8F72669C6aE649648B516ec03D07c8ED | ||
VEBO_ADDRESS=0xffDDF7025410412deaa05E3E1cE68FE53208afcb | ||
CSM_STAKING_MODULE_ID=4 | ||
ETHERSCAN_URL=https://holesky.etherscan.io | ||
BEACONCHAIN_URL=https://holesky.beaconcha.in | ||
CSM_UI_URL=https://csm.testnet.fi/?ref=ethpillar | ||
EOF | ||
;; | ||
*) | ||
echo "Unsupported network" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
# Start docker container | ||
cd /opt/ethpillar/plugin-sentinel/csm-sentinel | ||
sudo docker run -d --env-file=.env --name csm-sentinel -v csm-sentinel-persistent:/app/.storage csm-sentinel | ||
|
||
MSG_COMPLETE="Done! Congratulations on your new locally hosted CSM Sentinel bot. | ||
\nYou will find it at t.me/[YOUR-BOT-NAME]. | ||
Follow your Node Operator id." | ||
|
||
# Intro screen | ||
whiptail --title "CSM Sentinel: Install Complete" --msgbox "$MSG_COMPLETE" 10 78 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters