From 98408bed1d473f727d577b7378edbec22b94d447 Mon Sep 17 00:00:00 2001 From: M_Viper Date: Sun, 28 Jan 2024 16:52:43 +0100 Subject: [PATCH] Dateien nach "/" hochladen --- setup.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ start_bot.sh | 3 +++ 2 files changed, 73 insertions(+) create mode 100644 setup.sh create mode 100644 start_bot.sh diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..a353a79 --- /dev/null +++ b/setup.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# Überprüfen, ob Node.js installiert ist +if ! command -v node &> /dev/null; then + echo "Node.js ist nicht installiert. Installiere Node.js automatisch..." + + # Automatische Installation von Node.js, abhängig vom Linux-System + if command -v apt &> /dev/null; then + sudo apt update + sudo apt install -y nodejs + elif command -v yum &> /dev/null; then + sudo yum install -y nodejs + else + echo "Automatische Installation von Node.js wird nicht unterstützt. Bitte installieren Sie Node.js manuell und führen Sie das Skript erneut aus." + exit 1 + fi +fi + +# Überprüfen, ob npm installiert ist +if ! command -v npm &> /dev/null; then + echo "npm ist nicht installiert. Installiere npm automatisch..." + sudo apt install -y npm # Oder passen Sie dies an Ihr System an +fi + +# Laden Sie die Umgebungsvariablen aus der .env-Datei +source .env + +# Erstellen Sie ein neues Node.js-Projekt mit npm init und verwenden Sie Umgebungsvariablen +echo -e "Creating a new Node.js project..." +echo -e "Project name: $PROJECT_NAME" +echo -e "Version: 1.0.0" +echo -e "Description: Node.js project" +echo -e "Entry point: support_bot.js" # Hier Dateinamen anpassen +echo -e "Test command: " +echo -e "Git repository: https://git.viper.ipv64.net/M_Viper/telegram_server_monitoring" +echo -e "Keywords: " +echo -e "Author: M_Viper" +echo -e "License: ISC" + +# npm init -y sollte ohne sudo ausgeführt werden, um Probleme mit Dateiberechtigungen zu vermeiden +sudo npm init -y + +# Installieren Sie die benötigten Pakete, einschließlich node-telegram-bot-api +sudo npm install +sudo npm install ping +sudo npm install node-telegram-bot-api +sudo npm install js-yaml +sudo npm install moment +sudo npm install yaml # Änderung: 'yaml' anstelle von 'yml' +sudo npm install dotenv +sudo npm install fs +sudo npm install request +sudo npm install nodemailer +sudo npm install axios + +# Installieren Sie pm2, wenn es noch nicht installiert ist +if ! command -v pm2 &> /dev/null; then + sudo npm install -g pm2 +fi + +# Erstellen Sie ein Startskript für den Bot +echo -e "Creating start script..." +echo -e "#!/bin/bash\n\npm2 start support_bot.js" > start_bot.sh # Hier Dateinamen anpassen +chmod +x start_bot.sh + +# Erstellen Sie ein Autostart-Skript für den Bot +echo -e "Creating autostart script..." +echo -e "[Unit]\nDescription=Telegram Support Bot\n\n[Service]\nExecStart=$(pwd)/start_bot.sh\n\n[Install]\nWantedBy=default.target" > telegram_bot.service +sudo mv telegram_bot.service /etc/systemd/system/ +sudo systemctl enable telegram_bot \ No newline at end of file diff --git a/start_bot.sh b/start_bot.sh new file mode 100644 index 0000000..ac2b9fe --- /dev/null +++ b/start_bot.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +pm2 start support_bot.js