- Install golang: go.dev/doc/install
- Clone repo:
md youtube-bot && cd youtube-bot
git clone https://github.com/tecspda/get-img-from-youtube-bot.git .- Initialize the Golang project
go mod init modules
go mod tidyGOOS=linux GOARCH=amd64 go build -o youtubeimgbotIn this example, the amd64 parameter is specified for compiling the executable file for Linux x86. If you want to compile for your system, enter the command
go build youtubeimgbotIf you compiled the bot on your local computer:
- Copy only three files to the server:
youtubeimgbot.sh,youtubeimgbot,.env. - Don't forget to set the permissions:
cd /var/www/bots/get_youtube_img_bot
chmod 0775 youtubeimgbot.*
- Create a directory uploads on the server. Grant 775 permissions.
- Регистрация бота
- Rename the example.env file to .env and enter the bot key (see the above point)
sudo nano /etc/systemd/system/youtubeimgbot.service[Unit]
Description=Youtube bot Service
After=network.target
[Service]
ExecStart=/var/www/bots/get_youtube_img_bot/youtubeimgbot.sh
Restart=always
[Install]
WantedBy=default.target
systemctl start youtubeimgbot
systemctl status youtubeimgbot
systemctl enabled youtubeimgbotCongratulations! Your standalone bot is now running on the server.