Skip to content

Commit af03df2

Browse files
doc: 📚 docs updated
1 parent a35ded6 commit af03df2

15 files changed

+175
-79
lines changed

README.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ To use HackScripts, you can clone the repository and run the scripts that you ne
1111

1212
## Scripts List
1313

14-
| Script | Description | Status |
15-
| --- | --- | --- |
16-
| [setup_time_sync.sh](server/setup_time_sync.sh) | Description not set | Tested |
17-
| [notification.sh](other/notification.sh) | Description not set | Tested |
18-
| [create_conda_env.sh](setup/create_conda_env.sh) | Description not set | Tested |
19-
| [setup_vscode.sh](setup/setup_vscode.sh) | Description not set | Tested |
20-
| [setup_gh_ssh.sh](setup/setup_gh_ssh.sh) | Description not set | Tested |
21-
| [basic_setup.sh](setup/basic_setup.sh) | Description not set | Tested |
22-
| [install_miniconda.sh](setup/install_miniconda.sh) | Description not set | Tested |
23-
| [setup_docker.sh](setup/setup_docker.sh) | Description not set | Tested |
24-
| [setup_ssh.sh](setup/setup_ssh.sh) | Description not set | Tested |
25-
| [install_fail2ban.sh](security/install_fail2ban.sh) | Description not set | Tested |
26-
| [table_generator.sh](table_generator.sh) | Description not set | Tested |
27-
| [setup_redis_server.sh](database/setup_redis_server.sh) | Description not set | Tested |
28-
| [setup_postgres.sh](database/setup_postgres.sh) | Description not set | Tested |
14+
| Script | Description | Status | Published By | Published On |
15+
| --- | --- | --- | --- | --- |
16+
[notification.sh](other/notification.sh) | Function to send notifications | tested | Deepak Raj | 2024-08-30 |
17+
[setup_gh_ssh.sh](setup/setup_gh_ssh.sh) | Script to setup SSH keys for multiple GitHub accounts | tested | Deepak Raj | 2024-08-29 |
18+
[setup_vscode.sh](setup/setup_vscode.sh) | Script to install Visual Studio Code on a Linux system | tested | Deepak Raj | 2024-08-28 |
19+
[setup_time_sync.sh](server/setup_time_sync.sh) | This script sets up NTP or systemd-timesyncd on Ubuntu | tested | Deepak Raj | 2024-08-28 |
20+
[setup_ssh.sh](setup/setup_ssh.sh) | setup open ssh server on ubuntu | tested | Deepak Raj | 2024-08-28 |
21+
[setup_redis_server.sh](database/setup_redis_server.sh) | Script to setup Redis server on a Linux system | tested | Deepak Raj | 2024-08-28 |
22+
[setup_postgres.sh](database/setup_postgres.sh) | Script to setup PostgreSQL and pgAdmin on a Linux system | not tested | Deepak Raj | 2024-08-28 |
23+
[setup_docker.sh](setup/setup_docker.sh) | Script to install Docker and Docker Compose on a Linux system | tested | Deepak Raj | 2024-08-28 |
24+
[install_miniconda.sh](setup/install_miniconda.sh) | Script to setup Miniconda on a Linux system | tested | Deepak Raj | 2024-08-28 |
25+
[install_fail2ban.sh](security/install_fail2ban.sh) | Script to install and configure fail2ban on Ubuntu | tested | Deepak Raj | 2024-08-28 |
26+
[create_conda_env.sh](setup/create_conda_env.sh) | Script to create a new Conda environment with the latest Python version | tested | Deepak Raj | 2024-08-28 |
27+
[basic_setup.sh](setup/basic_setup.sh) | Script for basic server setup on a Linux system | tested | Deepak Raj | 2024-08-28 |
28+
2929

3030

3131
## Contributing

SCRIPT_TABLE.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
| Script | Description | Status | Published By | Published On |
2+
| --- | --- | --- | --- | --- |
3+
[notification.sh](other/notification.sh) | Function to send notifications | tested | Deepak Raj | 2024-08-30 |
4+
[setup_gh_ssh.sh](setup/setup_gh_ssh.sh) | Script to setup SSH keys for multiple GitHub accounts | tested | Deepak Raj | 2024-08-29 |
5+
[setup_vscode.sh](setup/setup_vscode.sh) | Script to install Visual Studio Code on a Linux system | tested | Deepak Raj | 2024-08-28 |
6+
[setup_time_sync.sh](server/setup_time_sync.sh) | This script sets up NTP or systemd-timesyncd on Ubuntu | tested | Deepak Raj | 2024-08-28 |
7+
[setup_ssh.sh](setup/setup_ssh.sh) | setup open ssh server on ubuntu | tested | Deepak Raj | 2024-08-28 |
8+
[setup_redis_server.sh](database/setup_redis_server.sh) | Script to setup Redis server on a Linux system | tested | Deepak Raj | 2024-08-28 |
9+
[setup_postgres.sh](database/setup_postgres.sh) | Script to setup PostgreSQL and pgAdmin on a Linux system | not tested | Deepak Raj | 2024-08-28 |
10+
[setup_docker.sh](setup/setup_docker.sh) | Script to install Docker and Docker Compose on a Linux system | tested | Deepak Raj | 2024-08-28 |
11+
[install_miniconda.sh](setup/install_miniconda.sh) | Script to setup Miniconda on a Linux system | tested | Deepak Raj | 2024-08-28 |
12+
[install_fail2ban.sh](security/install_fail2ban.sh) | Script to install and configure fail2ban on Ubuntu | tested | Deepak Raj | 2024-08-28 |
13+
[create_conda_env.sh](setup/create_conda_env.sh) | Script to create a new Conda environment with the latest Python version | tested | Deepak Raj | 2024-08-28 |
14+
[basic_setup.sh](setup/basic_setup.sh) | Script for basic server setup on a Linux system | tested | Deepak Raj | 2024-08-28 |

database/setup_postgres.sh

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/bin/bash
22

3+
# Script to setup PostgreSQL and pgAdmin on a Linux system
4+
# status: not tested
5+
# published by: Deepak Raj
6+
# published on: 2024-08-28
7+
8+
39
# Exit immediately if a command exits with a non-zero status
410
set -e
511

database/setup_redis_server.sh

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
# Script to setup Redis server on a Linux system
4+
# status: tested
5+
# published by: Deepak Raj
6+
# published on: 2024-08-28
7+
38
# Exit immediately if a command exits with a non-zero status
49
set -e
510

other/notification.sh

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/bash
22

33
# Function to send notifications
4+
# status: tested
5+
# published by: Deepak Raj
6+
# published on: 2024-08-30
7+
48
send_notification() {
59
notify-send "Notification" "You Have been hacked"
610
}

security/install_fail2ban.sh

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
22

33
# Script to install and configure fail2ban on Ubuntu
4+
# status: tested
5+
# published by: Deepak Raj
6+
# published on: 2024-08-28
47

58
# Check if the script is run as root
69
if [ "$EUID" -ne 0 ]; then

server/setup_time_sync.sh

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
22

33
# This script sets up NTP or systemd-timesyncd on Ubuntu
4+
# status: tested
5+
# published by: Deepak Raj
6+
# published on: 2024-08-28
47

58
# Function to install and configure NTP
69
install_ntp() {

setup/basic_setup.sh

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
# Script for basic server setup on a Linux system
4+
# status: tested
5+
# published by: Deepak Raj
6+
# published on: 2024-08-28
7+
38
# indian timezone
49
NEW_USER="admin"
510
TIMEZONE="Asia/Kolkata"

setup/create_conda_env.sh

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
22

33
# Script to create a new Conda environment with the latest Python version
4+
# status: tested
5+
# published by: Deepak Raj
6+
# published on: 2024-08-28
47

58
# Check if the script is run with an argument for the environment name
69
if [ "$#" -ne 1 ]; then

setup/install_miniconda.sh

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
# Script to setup Miniconda on a Linux system
4+
# status: tested
5+
# published by: Deepak Raj
6+
# published on: 2024-08-28
7+
38
# Check if the script is run as root
49
if [ "$EUID" -ne 0 ]; then
510
echo "Please run as root or use sudo."

setup/setup_docker.sh

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
# Script to install Docker and Docker Compose on a Linux system
4+
# status: tested
5+
# published by: Deepak Raj
6+
# published on: 2024-08-28
7+
38
# Check if the script is run as root
49
if [ "$EUID" -ne 0 ]; then
510
echo "Please run as root or use sudo."

setup/setup_gh_ssh.sh

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
# Script to setup SSH keys for multiple GitHub accounts
4+
# status: tested
5+
# published by: Deepak Raj
6+
# published on: 2024-08-29
7+
38
# Exit immediately if a command exits with a non-zero status
49
set -e
510

setup/setup_ssh.sh

+56-51
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,56 @@
1-
#!/bin/bash
2-
3-
# Check if the script is run as root
4-
if [ "$EUID" -ne 0 ]; then
5-
echo "Please run as root"
6-
exit 1
7-
fi
8-
9-
# Install OpenSSH Server
10-
echo "Installing OpenSSH Server..."
11-
apt-get update
12-
apt-get install -y openssh-server
13-
14-
# Enable and start the SSH service
15-
echo "Enabling and starting the SSH service..."
16-
systemctl enable ssh
17-
systemctl start ssh
18-
19-
# Install UFW (Uncomplicated Firewall)
20-
echo "Installing UFW (Uncomplicated Firewall)..."
21-
apt-get install -y ufw
22-
23-
# Allow SSH through the firewall
24-
echo "Allowing SSH traffic on port 22..."
25-
ufw allow 22/tcp
26-
27-
# Enable the firewall
28-
echo "Enabling the firewall..."
29-
ufw enable
30-
31-
# Get the server's IP address
32-
IP_ADDRESS=$(hostname -I | awk '{print $1}')
33-
if [ -z "$IP_ADDRESS" ]; then
34-
echo "Could not retrieve IP address. Please check your network settings."
35-
exit 1
36-
fi
37-
38-
# Get the current username
39-
USERNAME=$(whoami)
40-
41-
# Display the login information
42-
echo "====================================="
43-
echo "OpenSSH Server has been installed and configured."
44-
echo "You can access this server using the following information:"
45-
echo ""
46-
echo "IP Address: $IP_ADDRESS"
47-
echo "Username: $USERNAME"
48-
echo ""
49-
echo "To log in from another machine, use the following command:"
50-
echo "ssh $USERNAME@$IP_ADDRESS"
51-
echo "====================================="
1+
#!/bin/bash
2+
3+
# setup open ssh server on ubuntu
4+
# status: tested
5+
# published by: Deepak Raj
6+
# published on: 2024-08-28
7+
8+
# Check if the script is run as root
9+
if [ "$EUID" -ne 0 ]; then
10+
echo "Please run as root"
11+
exit 1
12+
fi
13+
14+
# Install OpenSSH Server
15+
echo "Installing OpenSSH Server..."
16+
apt-get update
17+
apt-get install -y openssh-server
18+
19+
# Enable and start the SSH service
20+
echo "Enabling and starting the SSH service..."
21+
systemctl enable ssh
22+
systemctl start ssh
23+
24+
# Install UFW (Uncomplicated Firewall)
25+
echo "Installing UFW (Uncomplicated Firewall)..."
26+
apt-get install -y ufw
27+
28+
# Allow SSH through the firewall
29+
echo "Allowing SSH traffic on port 22..."
30+
ufw allow 22/tcp
31+
32+
# Enable the firewall
33+
echo "Enabling the firewall..."
34+
ufw enable
35+
36+
# Get the server's IP address
37+
IP_ADDRESS=$(hostname -I | awk '{print $1}')
38+
if [ -z "$IP_ADDRESS" ]; then
39+
echo "Could not retrieve IP address. Please check your network settings."
40+
exit 1
41+
fi
42+
43+
# Get the current username
44+
USERNAME=$(whoami)
45+
46+
# Display the login information
47+
echo "====================================="
48+
echo "OpenSSH Server has been installed and configured."
49+
echo "You can access this server using the following information:"
50+
echo ""
51+
echo "IP Address: $IP_ADDRESS"
52+
echo "Username: $USERNAME"
53+
echo ""
54+
echo "To log in from another machine, use the following command:"
55+
echo "ssh $USERNAME@$IP_ADDRESS"
56+
echo "====================================="

setup/setup_vscode.sh

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
# Script to install Visual Studio Code on a Linux system
4+
# status: tested
5+
# published by: Deepak Raj
6+
# published on: 2024-08-28
7+
38
# Exit immediately if a command exits with a non-zero status
49
set -e
510

table_generator.sh

+41-13
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,62 @@ SEARCH_DIR="." # Current directory
66
# Output file for the Markdown table
77
OUTPUT_FILE="SCRIPT_TABLE.md"
88

9+
# Temporary file to hold the unsorted data
10+
TEMP_FILE=$(mktemp)
11+
912
# Create or clear the output file
1013
> "$OUTPUT_FILE"
1114

12-
# Print the table header
13-
echo "| Script | Description | Status |" >> "$OUTPUT_FILE"
14-
echo "| --- | --- | --- |" >> "$OUTPUT_FILE"
15+
# Print the table header to the output file
16+
echo "| Script | Description | Status | Published By | Published On |" >> "$OUTPUT_FILE"
17+
echo "| --- | --- | --- | --- | --- |" >> "$OUTPUT_FILE"
1518

1619
# Find all .sh files in the specified directory and its subdirectories
1720
find "$SEARCH_DIR" -type f -name "*.sh" | while read -r script; do
1821
if [[ -f "$script" ]]; then
22+
# if table_generator.sh is found, skip it
23+
if [[ "$script" == *table_generator.sh ]]; then
24+
continue
25+
fi
1926
script_name=$(basename "$script")
2027
script_path=$(realpath --relative-to="$(pwd)" "$script")
28+
2129
description="Description not set"
22-
status="Tested"
30+
status="Not tested"
31+
published_by="Unknown"
32+
published_on="Unknown"
33+
34+
# Extract description from the script file
35+
description_line=$(grep -m 1 '^# ' "$script" | sed 's/^# //')
36+
if [[ -n "$description_line" ]]; then
37+
description="$description_line"
38+
fi
2339

24-
# Check for a description in the script (e.g., comments at the top)
25-
if grep -q "^# Description:" "$script"; then
26-
description=$(grep "^# Description:" "$script" | sed 's/^# Description: //')
40+
# Extract status from the script file
41+
if grep -q "^# status:" "$script"; then
42+
status=$(grep "^# status:" "$script" | sed 's/^# status: //')
2743
fi
2844

29-
# Check for a status in the script (e.g., comments at the top)
30-
if grep -q "^# Status:" "$script"; then
31-
status=$(grep "^# Status:" "$script" | sed 's/^# Status: //')
45+
# Extract published by from the script file
46+
if grep -q "^# published by:" "$script"; then
47+
published_by=$(grep "^# published by:" "$script" | sed 's/^# published by: //')
3248
fi
3349

34-
# Append the script information to the table
35-
echo "| [${script_name}](${script_path}) | ${description} | ${status} |" >> "$OUTPUT_FILE"
50+
# Extract published on from the script file
51+
if grep -q "^# published on:" "$script"; then
52+
published_on=$(grep "^# published on:" "$script" | sed 's/^# published on: //')
53+
fi
54+
55+
# Append the script information to the temp file
56+
echo "${published_on} | [${script_name}](${script_path}) | ${description} | ${status} | ${published_by} | ${published_on} |" >> "$TEMP_FILE"
3657
fi
3758
done
3859

39-
echo "Markdown table generated in $OUTPUT_FILE."
60+
# Sort the temp file by date (published_on) in reverse order and append to the output file
61+
# The sorting is done based on the first field (the date) in the temp file.
62+
sort -r -t '|' -k1,1 "$TEMP_FILE" | cut -d '|' -f 2- >> "$OUTPUT_FILE"
63+
64+
# Clean up the temp file
65+
rm "$TEMP_FILE"
66+
67+
echo "Markdown table generated in $OUTPUT_FILE, sorted by Published On date."

0 commit comments

Comments
 (0)