If you'd like to add some delays between the various steps in your script, you can use the sleep command in Bash. This command pauses the execution of the script for a specified number of seconds. Below is the modified script with delays added.
Here's the updated content for your setup_script.sh:
#!/bin/bash
# Navigate to the directory and rename .pem files
cd /etc/artcertificate || { echo "Directory not found"; exit 1; }
echo "Renaming .pem files..."
sleep 1 # Pause for 1 second
for file in *.pem; do
new_file="${file%.pem}.renamed.pem" # Change this pattern as needed for renaming
mv "$file" "$new_file"
echo "Renamed $file to $new_file"
done
sleep 1 # Pause for 1 second
# Navigate to /usr/sbin and comment the 3rd line in enable_ipv4.sh
cd /usr/sbin/ || { echo "Directory not found"; exit 1; }
if [ -f enable_ipv4.sh ]; then
echo "Commenting the 3rd line in enable_ipv4.sh..."
sleep 1 # Pause for 1 second
sed -i '3s/^/# /' enable_ipv4.sh
else
echo "enable_ipv4.sh not found"
fi
sleep 1 # Pause for 1 second
# Comment the last 2 lines in artnetworksetup.sh
if [ -f artnetworksetup.sh ]; then
echo "Commenting the last two lines in artnetworksetup.sh..."
sleep 1 # Pause for 1 second
sed -i '$ s/^/# /' artnetworksetup.sh # Comment the last line
sed -i '$!b;n; s/^/# /' artnetworksetup.sh # Comment second to last line
else
echo "artnetworksetup.sh not found"
fi
sleep 1 # Pause for 1 second
# Remove the specified files
echo "Removing /etc/iptables/lavu.rules and /etc/iptables/lavu_v6.rules..."
sleep 1 # Pause for 1 second
rm -f /etc/iptables/lavu.rules
rm -f /etc/iptables/lavu_v6.rules
# Append the two specified lines to artnetworksetup.sh
{
echo "/usr/sbin/enable_ipv4.sh"
echo "udhcpc -i eth0"
} >> artnetworksetup.sh
echo "Added lines to artnetworksetup.sh..."
sleep 1 # Pause for 1 second
# Run the modified artnetworksetup.sh script
echo "Making artnetworksetup.sh executable and running..."
chmod +x artnetworksetup.sh
sleep 1 # Pause for 1 second
./artnetworksetup.sh
Key Changes:
- Added
sleep Commands: A sleep command is added after several key actions to introduce delays of 1 second. You can adjust these delays as necessary by changing the number of seconds in the sleep command.
- Echo Statements: Additional echo statements provide status updates to indicate what the script is doing at each step.
Usage:
The usage remains the same as before:
- Save the script in a file called
setup_script.sh.
- Make it executable:
chmod +x setup_script.sh
- Run the script using:
sudo ./setup_script.sh
This modified script will now have pauses, which may help if you need to visually track progress or if the system requires time to complete certain tasks. Adjust the sleep durations according to your specific requirements.