!esyCFwsvHGqLXuAxSC:matrix.org

Fun Shell Scripting

346 Members
Functional shell scripting knowledge exchange for UNIX experts. MUC bridge: xmpp:fun-shell@conference.movim.eu wikibooks.org/wiki/Bourne_Shell_Scripting tldp.org/LDP/Bash-Beginners-Guide/html github.com/Idnan/bash-guide github.com/lhunath/guide.bash.academy github.com/koalaman/shellcheck github.com/learnbyexample/learn_gnuawk manpages.ubuntu.com/manpages/bionic/man1/checkbashisms.1.html linuxcommand.org Let's review functions in live systems! Share funny snippets or discuss bugs. All variants welcome: BSD, Linux, POSIX, busybox, ash, sash, dash, bash, ksh93, zsh, mksh, pdksh, yash, bosh, posh, csh, tcsh, scsh, es, rash, xshell, ion, nushell, xonsh, oilshell, powershell, fish, elvish, execline, putty, grep, sed, awk. You agree to share snippets under the public domain (unless you otherwise declare it). Report abuse by typing !modhelp Examples shellscript.sh github.com/openwrt/openwrt/tree/master/package/base-files/files codeberg.org/Sapphire/sapphire-butler/src/branch/master/departments github.com/pacstall/pacstall-programs35 Servers

Load older messages


SenderMessageTime
13 Feb 2024
@hashborgir:mozilla.orgπŸ„ HB|B.CS,BSCSIA,A+,Net+,Sec+,CySA+,Pentest+,Project+,ECES,ITILv4,SSCP,MCP,MCSE|🌿 *
#!/bin/bash

# Function to prompt user for input
prompt_user() {
    read -p "$1: " input
    echo "$input"
}

# Store current directory
current_dir=$(pwd)

# Setup python virtual environment
python3 -m venv venv
source venv/bin/activate

# Clone the simplematrixbotlib repository
git clone https://codeberg.org/imbev/simplematrixbotlib.git

# Copy the patch file to the simplematrixbotlib directory
cp 0001-Fix-stability-issue-in-api.py.patch $current_dir/simplematrixbotlib/

# Change directory to simplematrixbotlib
cd $current_dir/simplematrixbotlib/

# Apply the patch
git apply 0001-Fix-stability-issue-in-api.py.patch

# Remove the patch file

rm 0001-Fix-stability-issue-in-api.py.patch

# Install simplematrixbotlib
pip install .

# Change back to the original directory
cd $current_dir

# Install requirements
pip install -r requirements.txt

# Create .env file with required content
echo -e "MATRIX_URL = \"https://matrix.org\"\nMATRIX_USER = \"\"\nMATRIX_PASS = \"\"" > .env

# Print ASCII art
echo " _____                                ____        _     "
echo "|  ___|   _ _ __   __ _ _   _ _   _  | __ )  ___ | |_   "
echo "| |_ | | | | '_ \ / _\` | | | | | | | |  _ \ / _ \| __|  "
echo "|  _|| |_| | | | | (_| | |_| | |_| | | |_) | (_) | |_   "
echo "|_|   \__,_|_| |_|\__, |\__,_|\__, | |____/ \___/ \__|  "
echo "                  |___/        |___/                     "
echo "             By HB (@hashborgir@mozilla.org)"
echo "--------------------------------------------------------"
# Echo setup completion message
echo ""
echo "Bot setup completed."

# Prompt user to modify funguy.py to set ADMIN_USER
echo "Modify .env file and set your credentials and homeserver"
echo "Please open funguy.py and set the ADMIN_USER variable to your admin username."

# Prompt the user if they want to set up the systemd service
response=$(prompt_user "Do you want me to set up the systemd service to launch the bot? (Y/n): ")

# Check the response
if [[ $response =~ ^[Yy](es)?$ ]]; then
    echo "Yes, setting up systemd service."

    # Check if script is run with sudo
    if [[ $EUID -ne 0 ]]; then
    echo "This script requires sudo privileges to run. Please enter your sudo password:"
    sudo -v
    if [ $? -eq 0 ]; then
        echo "Successfully obtained sudo privileges"
    else
        echo "Failed to obtain sudo privileges. Exiting."
        exit 1
    fi
    fi

    # Check if funguy.py and plugins/ directory exist in current directory
    if [ -f "funguy.py" ] && [ -d "plugins" ]; then
        working_directory=$(pwd)
    else
        working_directory=$(prompt_user "Enter working directory where bot is installed")
        if [ ! -d "$working_directory" ]; then
            echo "Error: Working directory does not exist"
            exit 1
        fi
    fi

    # Prompt for user and group
    user=$(prompt_user "Enter user")
    same_group=$(prompt_user "Is group same as user? (Y/n): ")
    if [[ $same_group =~ ^[Yy]$ ]]; then
        group=$user
    else
        group=$(prompt_user "Enter group")
    fi

    # Create systemd service file
    cat <<EOF > /etc/systemd/system/funguybot.service
[Unit]
Description=Funguy Bot Service
After=network.target

[Service]
Type=simple
User=$user
Group=$group
WorkingDirectory=$working_directory
ExecStart=$working_directory/start-funguy.sh
Restart=on-failure
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=funguybot

[Install]
WantedBy=multi-user.target
EOF

    # Enable and start the service
    systemctl daemon-reload
    systemctl enable funguybot
    systemctl start funguybot

    echo "Starting service..."
    sleep 2

    # Check if service is running
    if systemctl is-active --quiet funguybot; then
        echo "Funguy bot service installed, enabled, and started successfully"

    else
        echo "The service is not running. Check the logs."
    fi

else
    echo "No, not setting up systemd service."
fi

21:45:17
@hashborgir:mozilla.orgπŸ„ HB|B.CS,BSCSIA,A+,Net+,Sec+,CySA+,Pentest+,Project+,ECES,ITILv4,SSCP,MCP,MCSE|🌿 *
21:46:25
@hashborgir:mozilla.orgπŸ„ HB|B.CS,BSCSIA,A+,Net+,Sec+,CySA+,Pentest+,Project+,ECES,ITILv4,SSCP,MCP,MCSE|🌿 *
#!/bin/bash

# Function to prompt user for input
prompt_user() {
    read -p "$1: " input
    echo "$input"
}

# Store current directory
current_dir=$(pwd)

# Setup python virtual environment
python3 -m venv venv
source venv/bin/activate

# Clone the simplematrixbotlib repository
git clone https://codeberg.org/imbev/simplematrixbotlib.git

# Copy the patch file to the simplematrixbotlib directory
cp 0001-Fix-stability-issue-in-api.py.patch $current_dir/simplematrixbotlib/

# Change directory to simplematrixbotlib
cd $current_dir/simplematrixbotlib/

# Apply the patch
git apply 0001-Fix-stability-issue-in-api.py.patch

# Remove the patch file

rm 0001-Fix-stability-issue-in-api.py.patch

# Install simplematrixbotlib
pip install .

# Change back to the original directory
cd $current_dir

# Install requirements
pip install -r requirements.txt

# Create .env file with required content
echo -e "MATRIX_URL = \"https://matrix.org\"\nMATRIX_USER = \"\"\nMATRIX_PASS = \"\"" > .env

# Print ASCII art
echo " _____                                ____        _     "
echo "|  ___|   _ _ __   __ _ _   _ _   _  | __ )  ___ | |_   "
echo "| |_ | | | | '_ \ / _\` | | | | | | | |  _ \ / _ \| __|  "
echo "|  _|| |_| | | | | (_| | |_| | |_| | | |_) | (_) | |_   "
echo "|_|   \__,_|_| |_|\__, |\__,_|\__, | |____/ \___/ \__|  "
echo "                  |___/        |___/                     "
echo "             By HB (@hashborgir@mozilla.org)"
echo "--------------------------------------------------------"
# Echo setup completion message
echo ""
echo "Bot setup completed."

# Prompt user to modify funguy.py to set ADMIN_USER
echo "Modify .env file and set your credentials and homeserver"
echo "Please open funguy.py and set the ADMIN_USER variable to your admin username."

# Prompt the user if they want to set up the systemd service
response=$(prompt_user "Do you want me to set up the systemd service to launch the bot? (Y/n): ")

# Check the response
if [[ $response =~ ^[Yy](es)?$ ]]; then
    echo "Yes, setting up systemd service."

    # Check if script is run with sudo
    if [[ $EUID -ne 0 ]]; then
    echo "This script requires sudo privileges to run. Please enter your sudo password:"
    sudo -v
    if [ $? -eq 0 ]; then
        echo "Successfully obtained sudo privileges"
    else
        echo "Failed to obtain sudo privileges. Exiting."
        exit 1
    fi
    fi

    # Check if funguy.py and plugins/ directory exist in current directory
    if [ -f "funguy.py" ] && [ -d "plugins" ]; then
        working_directory=$(pwd)
    else
        working_directory=$(prompt_user "Enter working directory where bot is installed")
        if [ ! -d "$working_directory" ]; then
            echo "Error: Working directory does not exist"
            exit 1
        fi
    fi

    # Prompt for user and group
    user=$(prompt_user "Enter user")
    same_group=$(prompt_user "Is group same as user? (Y/n): ")
    if [[ $same_group =~ ^[Yy]$ ]]; then
        group=$user
    else
        group=$(prompt_user "Enter group")
    fi

    # Create systemd service file
    cat <<EOF > /etc/systemd/system/funguybot.service
[Unit]
Description=Funguy Bot Service
After=network.target

[Service]
Type=simple
User=$user
Group=$group
WorkingDirectory=$working_directory
ExecStart=$working_directory/start-funguy.sh
Restart=on-failure
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=funguybot

[Install]
WantedBy=multi-user.target
EOF

    # Enable and start the service
    systemctl daemon-reload
    systemctl enable funguybot
    systemctl start funguybot

    echo "Starting service..."
    sleep 2

    # Check if service is running
    if systemctl is-active --quiet funguybot; then
        echo "Funguy bot service installed, enabled, and started successfully"

    else
        echo "The service is not running. Check the logs."
    fi

else
    echo "No, not setting up systemd service."
fi
21:46:39
@hashborgir:mozilla.orgπŸ„ HB|B.CS,BSCSIA,A+,Net+,Sec+,CySA+,Pentest+,Project+,ECES,ITILv4,SSCP,MCP,MCSE|🌿 *
#!/bin/bash

# Function to prompt user for input
prompt_user() {
    read -p "$1: " input
    echo "$input"
}

# Store current directory
current_dir=$(pwd)

# Setup python virtual environment
python3 -m venv venv
source venv/bin/activate

# Clone the simplematrixbotlib repository
git clone https://codeberg.org/imbev/simplematrixbotlib.git

# Copy the patch file to the simplematrixbotlib directory
cp 0001-Fix-stability-issue-in-api.py.patch $current_dir/simplematrixbotlib/

# Change directory to simplematrixbotlib
cd $current_dir/simplematrixbotlib/

# Apply the patch
git apply 0001-Fix-stability-issue-in-api.py.patch

# Remove the patch file

rm 0001-Fix-stability-issue-in-api.py.patch

# Install simplematrixbotlib
pip install .

# Change back to the original directory
cd $current_dir

# Install requirements
pip install -r requirements.txt

# Create .env file with required content
echo -e "MATRIX_URL = \"https://matrix.org\"\nMATRIX_USER = \"\"\nMATRIX_PASS = \"\"" > .env

# Print ASCII art
echo " _____                                ____        _     "
echo "|  ___|   _ _ __   __ _ _   _ _   _  | __ )  ___ | |_   "
echo "| |_ | | | | '_ \ / _\` | | | | | | | |  _ \ / _ \| __|  "
echo "|  _|| |_| | | | | (_| | |_| | |_| | | |_) | (_) | |_   "
echo "|_|   \__,_|_| |_|\__, |\__,_|\__, | |____/ \___/ \__|  "
echo "                  |___/        |___/                     "
echo "             By HB (@hashborgir@mozilla.org)"
echo "--------------------------------------------------------"
# Echo setup completion message
echo ""
echo "Bot setup completed."

# Prompt user to modify funguy.py to set ADMIN_USER
echo "Modify .env file and set your credentials and homeserver"
echo "Please open funguy.py and set the ADMIN_USER variable to your admin username."

# Prompt the user if they want to set up the systemd service
response=$(prompt_user "Do you want me to set up the systemd service to launch the bot? (Y/n): ")

# Check the response
if [[ $response =~ ^[Yy](es)?$ ]]; then
    echo "Yes, setting up systemd service."

    # Check if script is run with sudo
    if [[ $EUID -ne 0 ]]; then
    echo "This script requires sudo privileges to run. Please enter your sudo password:"
    sudo -v
    if [ $? -eq 0 ]; then
        echo "Successfully obtained sudo privileges"
    else
        echo "Failed to obtain sudo privileges. Exiting."
        exit 1
    fi
    fi

    # Check if funguy.py and plugins/ directory exist in current directory
    if [ -f "funguy.py" ] && [ -d "plugins" ]; then
        working_directory=$current_dir
    else
        working_directory=$(prompt_user "Enter working directory where bot is installed")
        if [ ! -d "$working_directory" ]; then
            echo "Error: Working directory does not exist"
            exit 1
        fi
    fi

    # Prompt for user and group
    user=$(prompt_user "Enter user")
    same_group=$(prompt_user "Is group same as user? (Y/n): ")
    if [[ $same_group =~ ^[Yy]$ ]]; then
        group=$user
    else
        group=$(prompt_user "Enter group")
    fi

    # Create systemd service file
    cat <<EOF > /etc/systemd/system/funguybot.service
[Unit]
Description=Funguy Bot Service
After=network.target

[Service]
Type=simple
User=$user
Group=$group
WorkingDirectory=$working_directory
ExecStart=$working_directory/start-funguy.sh
Restart=on-failure
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=funguybot

[Install]
WantedBy=multi-user.target
EOF

    # Enable and start the service
    systemctl daemon-reload
    systemctl enable funguybot
    systemctl start funguybot

    echo "Starting service..."
    sleep 2

    # Check if service is running
    if systemctl is-active --quiet funguybot; then
        echo "Funguy bot service installed, enabled, and started successfully"

    else
        echo "The service is not running. Check the logs."
    fi

else
    echo "No, not setting up systemd service."
fi
21:48:36
@bkil:matrix.orgbkilm https://askubuntu.com/questions/1371102/running-systemd-service-as-user-rather-than-root
Running Systemd Service as User Rather Than Root
22:32:36
@bkil:matrix.orgbkilmAlthough, I understand that some would prefer to run it as a separate bot user and that would be easiest done via root.22:33:12
@tom_io:matrix.orgTomIO
In reply to @bkil:matrix.org
https://askubuntu.com/questions/1371102/running-systemd-service-as-user-rather-than-root
Running Systemd Service as User Rather Than Root

systemctl enable --user
(works for other commands like systemctl status too)
Quite useful, I actually have 2 user services as part of my dotfiles.
One to share my ssh-agent between all terminals in the session,
and one to autostart, and auto-restart KeePassXC.
https://github.com/TomJo2000/.dotfiles/tree/main/.local/share/systemd/user

Most of the info on user services is very old unforunately...

22:49:18
@tom_io:matrix.orgTomIO
In reply to @bkil:matrix.org
https://askubuntu.com/questions/1371102/running-systemd-service-as-user-rather-than-root
Running Systemd Service as User Rather Than Root
*

systemctl enable --user unit_name.service
(works for other commands like systemctl status too)
Quite useful, I actually have 2 user services as part of my dotfiles.
One to share my ssh-agent between all terminals in the session,
and one to autostart, and auto-restart KeePassXC.
https://github.com/TomJo2000/.dotfiles/tree/main/.local/share/systemd/user

Most of the info on user services is very old unforunately...

22:49:34
@tom_io:matrix.orgTomIOI'm sure you can do similar things with Runit or OpenRC.22:50:52
@tom_io:matrix.orgTomIO *

systemctl enable --user unit_name.service
(works for other commands like systemctl status --user too)
Quite useful, I actually have 2 user services as part of my dotfiles.
One to share my ssh-agent between all terminals in the session,
and one to autostart, and auto-restart KeePassXC.
https://github.com/TomJo2000/.dotfiles/tree/main/.local/share/systemd/user

Most of the info on user services is very old unforunately...

22:51:21
@hashborgir:mozilla.orgπŸ„ HB|B.CS,BSCSIA,A+,Net+,Sec+,CySA+,Pentest+,Project+,ECES,ITILv4,SSCP,MCP,MCSE|🌿 *

```sh
#!/bin/bash

# Function to prompt user for input
prompt_user() {
read -p "$1: " input
echo "$input"
}

# Store current directory
current_dir=$(pwd)

# Setup python virtual environment
python3 -m venv venv
source venv/bin/activate

# Clone the simplematrixbotlib repository
git clone https://codeberg.org/imbev/simplematrixbotlib.git

# Copy the patch file to the simplematrixbotlib directory
cp 0001-Fix-stability-issue-in-api.py.patch $current_dir/simplematrixbotlib/

# Change directory to simplematrixbotlib
cd $current_dir/simplematrixbotlib/

# Apply the patch
git apply 0001-Fix-stability-issue-in-api.py.patch

# Remove the patch file

rm 0001-Fix-stability-issue-in-api.py.patch

# Install simplematrixbotlib
pip install .

# Change back to the original directory
cd $current_dir

# Install requirements
pip install -r requirements.txt

# Create .env file with required content
echo -e "MATRIX_URL = "https://matrix.org"\nMATRIX_USER = ""\nMATRIX_PASS = """ > .env

# Print ASCII art
echo " _____ ____ _ "
echo "| | _ _ __ __ _ _ _ _ _ | __ ) ___ | | "
echo "| |
| | | | '
\ / ` | | | | | | | | _ \ / _ | __| "
echo "| || || | | | | (
| | || | || | | |) | () | |_ "
echo "|| _,|| ||_, |_,|_, | |___/ ___/ _| "
echo " |
/ |_/ "
echo " By HB (@hashborgir@mozilla.org)"
echo "--------------------------------------------------------"

Echo setup completion message

echo ""
echo "Bot setup completed."

# Prompt user to modify funguy.py to set ADMIN_USER
echo "Modify .env file and set your credentials and homeserver"
echo "Please open funguy.py and set the ADMIN_USER variable to your admin username."

# Prompt the user if they want to set up the systemd service
response=$(prompt_user "Do you want me to set up the systemd service to launch the bot? (Y/n): ")

# Check the response
if [[ response =~ ^[Yy](es)? ]]; then
echo "Yes, setting up systemd service."

# Check if script is run with sudo
if [[ $EUID -ne 0 ]]; then
echo "This script requires sudo privileges to run. Please enter your sudo password:"
sudo -v
if [ $? -eq 0 ]; then
echo "Successfully obtained sudo privileges"
else
echo "Failed to obtain sudo privileges. Exiting."
exit 1
fi
fi

# Check if funguy.py and plugins/ directory exist in current directory
if [ -f "funguy.py" ] && [ -d "plugins" ]; then
working_directory=$current_dir
else
working_directory=$(prompt_user "Enter working directory where bot is installed")
if [ ! -d "$working_directory" ]; then
echo "Error: Working directory does not exist"
exit 1
fi
fi

# Prompt for user and group
user=$(prompt_user "Enter user")
same_group=$(prompt_user "Is group same as user? (Y/n): ")
if [[ same_group =~ ^[Yy] ]]; then
group=$user
else
group=$(prompt_user "Enter group")
fi

# Create systemd service file
cat <<EOF > /etc/systemd/system/funguybot.service
[Unit]
Description=Funguy Bot Service
After=network.target

[Service]
Type=simple
User=$user
Group=$group
WorkingDirectory=$working_directory
ExecStart=$working_directory/start-funguy.sh
Restart=on-failure
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=funguybot

[Install]
WantedBy=multi-user.target
EOF

# Enable and start the service
systemctl daemon-reload
systemctl enable funguybot
systemctl start funguybot

echo "Starting service..."
sleep 2

# Check if service is running
if systemctl is-active --quiet funguybot; then
echo "Funguy bot service installed, enabled, and started successfully"

else
echo "The service is not running. Check the logs."
fi

else
echo "No, not setting up systemd service."
fi

23:30:25
@hashborgir:mozilla.orgπŸ„ HB|B.CS,BSCSIA,A+,Net+,Sec+,CySA+,Pentest+,Project+,ECES,ITILv4,SSCP,MCP,MCSE|🌿
#!/bin/bash

# Function to handle errors
handle_error() {
    echo "Error: $1"
    exit 1
}

# Function to handle sudo errors
handle_sudo_error() {
    echo -e "\e[31mError: Failed to execute sudo command: $1\e[0m"
    exit 1
}

# Function to execute sudo commands with error handling
sudo_execute() {
    echo -e "\e[31m$ sudo $@\e[0m"
    sudo "$@" || handle_sudo_error "$*"
}

# Function to create .env file with provided content
create_env() {
    echo -e "MATRIX_URL = \"$1\"\nMATRIX_USER = \"$2\"\nMATRIX_PASS = \"$3\"" > .env || handle_error "Failed to create .env file"
}

# Function to prompt user for input
prompt_user() {
    read -p "$1: " input
    echo "$input"
}

# Store current directory
current_dir=$(pwd)

# Setup python virtual environment
python3 -m venv venv
source venv/bin/activate

# Check if simplematrixbotlib directory already exists
if [ -d "simplematrixbotlib" ] && [ "$(ls -A simplematrixbotlib)" ]; then
    echo "simplematrixbotlib directory already exists."
else
    # Clone the simplematrixbotlib repository
    git clone https://codeberg.org/imbev/simplematrixbotlib.git || handle_error "Failed to clone simplematrixbotlib repository"
fi

# Copy the patch file to the simplematrixbotlib directory
cp api.py.patch "$current_dir/simplematrixbotlib/" || handle_error "Failed to copy patch file"

# Change directory to simplematrixbotlib
cd "$current_dir/simplematrixbotlib/" || handle_error "Failed to change directory to simplematrixbotlib"

# Apply the patch
git apply api.py.patch || handle_error "Failed to apply patch"

# Install simplematrixbotlib
pip install . || handle_error "Failed to install simplematrixbotlib"

# Change back to the original directory
cd "$current_dir"

# Install requirements
pip install -r requirements.txt || handle_error "Failed to install requirements"

# Prompt for Matrix homeserver
read -p "Do you want to use the default homeserver https://matrix.org? (Y/n): " use_default_hs
if [[ $use_default_hs =~ ^[Nn]$ ]]; then
    homeserver=$(prompt_user "Enter Matrix homeserver URL (e.g., example.com): ")
    homeserver="https://$homeserver"
else
    homeserver="https://matrix.org"
fi

# Prompt for username
username=$(prompt_user "Enter Matrix username: ")

# Prompt for password
password=$(prompt_user "Enter Matrix password: ")

# Create .env file
create_env "$homeserver" "$username" "$password"

# Print ASCII art
cat << "EOF"
 _____                                ____        _
|  ___|   _ _ __   __ _ _   _ _   _  | __ )  ___ | |_
| |_ | | | | '_ \ / _\` | | | | | | | |  _ \ / _ \| __|
|  _|| |_| | | | | (_| | |_| | |_| | | |_) | (_) | |_
|_|   \__,_|_| |_|\__, |\__,_|\__, | |____/ \___/ \__|
                  |___/        |___/
             By HB (@hashborgir@mozilla.org)
--------------------------------------------------------
EOF

# Echo setup completion message
echo "Setting up funguy bot..."
echo "Setting up systemd service..."

working_directory=$current_dir

# Prompt for user and group
user=$(prompt_user "Enter user")
same_group=$(prompt_user "Is group same as user? (Y/n): ")
if [[ $same_group =~ ^[Yy]$ ]]; then
    group=$user
else
    group=$(prompt_user "Enter group")
fi

# Create systemd service file
cat <<EOF > funguybot.service
[Unit]
Description=Funguy Bot Service
After=network.target

[Service]
Type=simple
User=$user
Group=$group
WorkingDirectory=$working_directory
ExecStart=$working_directory/start-funguy.sh
Restart=on-failure
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=funguybot

[Install]
WantedBy=multi-user.target
EOF

# Copy systemd service file
sudo_execute cp funguybot.service /etc/systemd/system/ || handle_sudo_error "Failed to copy systemd service file"

# Enable and start the service
sudo_execute systemctl daemon-reload || handle_sudo_error "Failed to reload systemd daemon"
sudo_execute systemctl enable funguybot || handle_sudo_error "Failed to enable funguybot service"
sudo_execute systemctl start funguybot || handle_sudo_error "Failed to start funguybot service"

echo "Funguy bot has been successfully installed and the service has been enabled."
echo "Before starting the service, make sure to edit the .env file and add your bot account's homeserver URL, username, and password."
echo ""
echo "Once done, start the service by running the following command:"
echo ""
echo ""
echo "sudo systemctl start funguybot"
23:30:39
@hashborgir:mozilla.orgπŸ„ HB|B.CS,BSCSIA,A+,Net+,Sec+,CySA+,Pentest+,Project+,ECES,ITILv4,SSCP,MCP,MCSE|🌿
#!/bin/bash

# Function to handle errors
handle_error() {
    echo "Error: $1"
    exit 1
}

# Load Python virtual environment
source venv/bin/activate || { echo "Error: Failed to load Python virtual environment."; exit 1; }

# Get python path
python=$(which python)

# Run funguy.py
$python /funguy.py || { echo "Error: Failed to execute funguy.py."; exit 1; }
23:31:10
@hashborgir:mozilla.orgπŸ„ HB|B.CS,BSCSIA,A+,Net+,Sec+,CySA+,Pentest+,Project+,ECES,ITILv4,SSCP,MCP,MCSE|🌿 *
#!/bin/bash
# Load Python virtual environment
source venv/bin/activate || { echo "Error: Failed to load Python virtual environment."; exit 1; }

# Get python path
python=$(which python)

# Run funguy.py
$python /funguy.py || { echo "Error: Failed to execute funguy.py."; exit 1; }
23:31:28
@hashborgir:mozilla.orgπŸ„ HB|B.CS,BSCSIA,A+,Net+,Sec+,CySA+,Pentest+,Project+,ECES,ITILv4,SSCP,MCP,MCSE|🌿Screenshot_20240213_163147.png
Download Screenshot_20240213_163147.png
23:31:50
@hashborgir:mozilla.orgπŸ„ HB|B.CS,BSCSIA,A+,Net+,Sec+,CySA+,Pentest+,Project+,ECES,ITILv4,SSCP,MCP,MCSE|🌿I don't see syntax highlighting in large code pieces. Only smaller ones. I use "```sh" 23:32:15
@hashborgir:mozilla.orgπŸ„ HB|B.CS,BSCSIA,A+,Net+,Sec+,CySA+,Pentest+,Project+,ECES,ITILv4,SSCP,MCP,MCSE|🌿 * I don't see syntax highlighting in large code pieces. Only smaller ones. I use "```sh" or bash 23:32:22
@hashborgir:mozilla.orgπŸ„ HB|B.CS,BSCSIA,A+,Net+,Sec+,CySA+,Pentest+,Project+,ECES,ITILv4,SSCP,MCP,MCSE|🌿 * I don't see syntax highlighting in large code pieces. Only smaller ones. I use "```sh" or bash ``` 23:32:30
@hashborgir:mozilla.orgπŸ„ HB|B.CS,BSCSIA,A+,Net+,Sec+,CySA+,Pentest+,Project+,ECES,ITILv4,SSCP,MCP,MCSE|🌿Is this a problem in element.io?23:32:50
@hashborgir:mozilla.orgπŸ„ HB|B.CS,BSCSIA,A+,Net+,Sec+,CySA+,Pentest+,Project+,ECES,ITILv4,SSCP,MCP,MCSE|🌿Screenshot_20240213_163541.png
Download Screenshot_20240213_163541.png
23:35:49
@hashborgir:mozilla.orgπŸ„ HB|B.CS,BSCSIA,A+,Net+,Sec+,CySA+,Pentest+,Project+,ECES,ITILv4,SSCP,MCP,MCSE|🌿Yay.23:35:53
14 Feb 2024
@xuserr:matrix.org@xuserr:matrix.org left the room.06:56:51
23 Feb 2024
@bkil:grin.hubkil https://forum.tinycorelinux.net/index.php/topic,25301.0.html
A git implementation in awk, File manager, Simple task/command runner with declarative goals and dependencies, tomnomnom/gron, dumb key/value store implemented in awk & plain-text files, Console roguelike, file manager awkventure includes some basic "Text-based user interface" ( read keypress / draw on terminal )

http://trevorjim.com/awk-unix-and-functional-programming/
Awk, Unix, and functional programming
11:45:34
@bkil:grin.hubkil
make implementation in awk
11:47:23
@kerouac:matrix.org~etienne changed their display name from Γ‰tienne to ~etienne.18:38:33
24 Feb 2024
@golu8:matrix.orggolu8what is difference between --sort=time and --sort=time --time=ctime in ls command13:33:07
@bkil:matrix.orgbkilm Defaults to mtime if you don't specify:
ctime (time of last modification of file status information)
13:45:34
26 Feb 2024
@keysersoze:tchncs.deKeyser SΓΆze banned @manoel2024:matrix.org@manoel2024:matrix.org (spam).00:01:18
27 Feb 2024
@.ztx:matrix.orgztx changed their profile picture.10:03:10
@iam_tj:matrix.orgiam_tj

Here's a neat (bash) function to provide aliases that can complete partial command names that someone asked about in Linux room:

__generic_command_finder() {
 # uses the function name as a stub to try to complete it into a command name using bash completion
 #  completion for commands searches PATH so given e.g:
 #   /usr/local/bin/myapp-version-1.2.3
 #  naming the function "myapp" and calling it will complete it to "myapp-version-1.2.3" and execute it
 iam="${FUNCNAME[0]}"
 cmd="$(compgen -A command "$iam" | while read -r c; do [ "$(type -t "$c")" != "function" ] && echo "$c"; done )"
 if [ -n "$cmd" ]; then
  echo "Executing $cmd"
  eval $cmd "$@"
 else
  >&2 echo "Error: cannot find a command using completion: '$iam'"
  return 1
 fi
}
12:33:18

There are no newer messages yet.


Back to Room ListRoom Version: 9