preface
#!/ bin/bash pid=`ps -aux | grep E5SubBot | grep -v 'grep' | awk '{print $2}'` if [ "$pid" != "" ]; then echo "running ..." else echo "$(date '+%Y/%m/%d %H:%M:%S'):no run,starting..." >> /root/e5cron.log echo "no run" cd /root/e5sub/ && nohup /root/e5sub/E5SubBot >> /root/e5sub/e5sub-$(date +%Y%m%d%H%M%S).log & fi
* */2 * * * /root/e5bot.sh
setup script
Access E5SubBot project address
Select the appropriate version
wget https://github.com/iyear/E5SubBot/releases/download/v0.2.1/E5SubBot_Linux_64bit.tar.gz
Unzip files
tar xvf E5SubBot_Linux_64bit.tar.gz
LICENSE README.md README_zhCN.md E5SubBot
Create folders and move files
#Create Folder mkdir /opt/e5sub #Move files mv E5SubBot /opt/e5sub/E5SubBot #Add execution permission to the file chmod a+x /opt/e5sub/E5SubBot
Installing the MYSQL database
#Download and install the MYSQL source wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm rpm -ivh mysql57-community-release-el7-10.noarch.rpm #Install Database yum install -y mysql-community-server
#If mysql57 is not used, please select the rpm of the corresponding version at the following address # https://repo.mysql.com/yum/ #You can also execute the following command to query all available versions yum repolist enabled | grep mysql #Disable the currently used 57 version yum-config-manager --disable mysql57-community #Select to enable using version 56 yum-config-manager --enable mysql56-community #Finally, perform the installation yum install -y mysql-community-server
systemctl start mysqld.service
#Obtain the password automatically generated by MySQL grep password /var/log/mysqld.log
2020-12-10T06:38:17.070043Z 1 [Note] A temporary password is generated for root@localhost : t; uY? tk&S2bT
Mysql - uroot - p 'password'
--Query the current password verification policy using the following SQL mysql> show variables like 'validate_password%'; --Set the MYSQL password verification policy to low mysql> set global validate_password_policy=0;
--Create the e5sub database and set the code mysql> CREATE DATABASE `e5sub` CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';
--Create e5sub user and set password mysql> CREATE USER `e5sub`@`localhost` IDENTIFIED BY 'e5sub'; --Authorize all permissions of the e5sub database to the e5sub user mysql> GRANT all ON `e5sub`.* TO `e5sub`@`localhost`; --Refresh Permissions mysql> FLUSH PRIVILEGES;
Configure E5Subbot
vim /opt/e5sub/config.yml
Bot_token: TOKEN of your TG robot Notice: "Here you can fill in the notification information of the robot" Admin: fill in your tg ID as administrator #socks5: 127.0.0.1:1080 errlimit: 15 cron: "1 */1 * * *" bindmax: 5 mysql: host: localhost port: 3306 user: e5sub password: e5sub database: e5sub
| |
---|---|
| |
| |
| |
| |
| |
| |
| |
| |
Write Systemd unit file
vim /etc/systemd/system/e5sub.service
[Unit] Description=Telegram E5Sub Bot [Service] Type=simple WorkingDirectory=/opt/e5sub ExecStart=/opt/e5sub/E5SubBot Restart=always RestartSec=30 [Install] WantedBy=multi-user.target
Set automatic startup
systemctl daemon-reload
systemctl start e5sub
systemctl status e5sub
systemctl enable e5sub