GithubHelp home page GithubHelp logo

marshalofficial / rsc.linuxadminassistant Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 39 KB

A Telegram bot that acts as a handy admin tool to update app folders and run shell commands

C# 97.01% Dockerfile 2.99%
admin assistant csharp telegram-bot server bot dockerize telegram

rsc.linuxadminassistant's Introduction

RSC.LinuxAdminAssistant

A Telegram bot that will act as an remote assistant on your server, you can run bash commands remotely on your server via this bot, also send your applications file updates to the bot and it will get a backup from target folder then unzip and replace new update for you.

Step by step guide:

  • create a new bot via TelegramBotFather and get your bot API key

  • create a Telegram group and add your bot as admin to the group

  • get a publish from the project and install it on your server(Linux/Windows)
    https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish

  • make sure that you installed dotnet 6 runtime on your server

  • copy publish folder on your server

  • run the project
    Linux: dotnet RSC.RSC.LinuxAdminAssistant.dll
    Windows: double click on RSC.RSC.LinuxAdminAssistant.exe

  • in my case to make the bot run in 7*24 I used supervisor application in linux:
    https://www.digitalocean.com/community/tutorials/how-to-install-and-manage-supervisor-on-ubuntu-and-debian-vps

  • now you can talk to bot in telegram group, to execute bash command, you must use this format:
    bash + * + YOURCOMMAND
    bash* date
    bash* ls
    bash* supervisorctl status all

  • if you send a zip file to the group, bot will search in a target folder that you set before in appsettings.json, and if find a folder with that name, will make a backup from that folder then unzip and replace zip file to the folder for you.

  • download*{path} for example: download*/etc/nginx/nginx.conf will download the target file for you into current chat

  • sending a file with this caption: upload*{path} for example: upload*/etc/nginx/nginx.conf will upload the file to the target path for you. (If the file doesn't exist it will create it there, otherwise, the bot will create a backup from the file by appending DateTime to the end of the file name and then replacing it for you)

  • Docker
    ** to run the project via docker, you need to build the image then run it, so inside the project folder run these below commands:
    1- docker build -t rsc-linux-assistant .
    2- docker run -d -e BotApiKey='YourBotApiKey' -e ProxyEnable='false' -e ProxyIP='127.0.0.1' -e ProxyPort='9050' -e AdminGroupId='YourTelegramGroupChatId' -e ServerBaseFolder='/home/X' -e ServerBackupFolder='/home/X/backups' --name test-assistant rsc-linux-assistant
    (note that you must pass all the configuration values that are inside appsettings.json as docker run environment variables)

  • WARNING: if your are running the bot as administrator or root, be careful what you send to call on your server ๐Ÿ˜‰.

rsc.linuxadminassistant's People

Contributors

marshalofficial avatar

Stargazers

 avatar  avatar

Watchers

 avatar

rsc.linuxadminassistant's Issues

permissions and user role management

A feature to handle user roles and permissions, when there are multiple users in the admin's Telegram group, we need to adjust who can run root privilege commands and who can't

download/upload(replace) config files

We need to add a feature to be able to download a file (config, txt, log and etc) via giving a command via file address to the bot, for example:
download*/etc/nginx/nginx.conf
then the admin will open the file from the Telegram group and edit it, then be able to update(replace) it via the bot,
send the target file via this comment: upload*/etc/nginx/nginx.conf

the bot must create the file in that path if currently is not exists.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.