This code is meant for maintaining official discord servers of CSE250, CSE251, CSE350, CSE460, and CSE428 at Brac University, Dhaka, Bangladesh.
If you have never run this code...
- Download the
credentials.jsonfile (rename if necessary) following this tutorial and keep it in the directory above. - Go to your pc's downloads folder:
ls Downloads/ - copy to server securely:
scp Downloads/credentials.json bot-250:~/ - to check:
- login as username:
ssh username@bot-250 - credentials file should be visable under home:
ls
- login as username:
- Developer portal
Here's a video recording of the process from Summer'23.
- If on windows, install Git Bash
- DigitalOcean -> Droplet -> 1Gib RAM ($6)
- SSH
ssh-keygen -t rsa -b 2048-> (Enter x3) -> default id_rsa, No passphrasels ~/.ssh->id_rsa,id_rsa.pubchmod 600 ~/.ssh/id_rsa-> chmod 600: users can read and write but no execute. groups and others don't have any access.chmod 600 ~/.ssh/id_rsa.pub->cat ~/.ssh/id_rsa.pubto show file content- share ssh-rsa
- add these "New Ssh-key" on DigitalOcean droplets.
- Static IP: Manage -> Networking -> Assign a Reserved IP.
- Not down the IP.
ssh root@IP_ADDRESS-> yes -> Enter.- If fails ->
ssh -i ~/.ssh/id_rsa root@IP_ADDRESS
- If fails ->
adduser username(e.g.adduser shs) -> password:123456usermod -aG sudo username(e.g.usermod -aG sudo shsvisudo-> edit file- add the following line under
root ALL=(ALL:ALL) ALL:username ALL=(ALL:ALL) ALL - For saving the file: press
CNTRL+O, thenENTER, thenCNTRL+X, thenENTER. - login as new username (always creates a user under a group with same username):
su username - go to home:
cd - create new ssh folder in new user's home:
mkdir ~/.ssh - go back to root user:
exit - copy root user's ssh to username's ssh:
cp ~/.ssh/authorized_keys /home/username/.ssh/ - change ownership to username (under the group username):
chown -R username:username /home/username/.ssh - login as username:
su username - change read access to ssh:
chmod -R go= ~/.ssh - go back to root user:
exit - go back to your pc:
exit - turn off root user login (only accessible by username login):
sudo nano /etc/ssh/sshd_config-> PermitRootLogin no - restart ssh:
sudo systemctl restart ssh.service - give
IP_ADDRESSa name: - on your pc, create a ssh config file:
nano ~/.ssh/config - add these lines (
bot-250is just a easily memorable name andIdentityFileis optional), end with a new line:
Host bot-250
Hostname IP_ADDRESS
User username
- if fails:
Host bot-250
Hostname IP_ADDRESS
User username
IdentityFile ~/.ssh/id_rsa
- now you should be able to login in an easier manner:
ssh username@bot-250 - Install Miniconda
- Get link to latest miniconda file. Right now it's:
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh - Download file:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh - check file name:
ls->Miniconda3-latest-Linux-x86_64.sh - start installation:
bash Miniconda3-latest-Linux-x86_64.sh - Enter for start, Space for more, "yes" for accepting (by default: "no")
- refresh bash source:
. ~/.bashrc - test if python is working:
which python
- Get link to latest miniconda file. Right now it's:
If you are re-running the code (e.g. in the beginning of the semester)
- Create a new folder and
cdto it:
mkdir summer_2023 && cd summer_2023- Clone this github repo (your directory must be empty) and make sure changes in
info.jsonis not tracked:
git clone https://github.com/shs-cse/discord-bot.git . && git update-index --skip-worktree info.json- Create a new server by copying the template https://discord.new/RVh3qBrGcsxA. The server name should follow the format
<course-code> <semester> <yyyy>, for example,CSE251 Fall 2022. - Add your discord bot the server and add
botrole to the bot. Also, make sure the bot is added to theEEE Course Team - BracU CSEserver. - Update the
info.jsonfile accordingly. - Start the bot by running the script
bash -i script.sh- To update
USIS (before)in the enrolment sheet, upload the.xlsfiles downloaded from USIS in any channel as a message, click "More > Apps > Update USIS (Before)". You may need to repeat this multiple times since you can only upload 10 files at a time.
To check the output/errors, open the tmux session using the command
tmux attach -t discordTo exit the session without closing it, press Ctrl+b, then d
- cd to the desired directory, e.g.,
cd ~/summer_2023- run the script
bash -i script.sh