I want to limit the upload bandwidth limit of the linux version of 115.com webapp. This webapp actually is run by "sh /usr/local/115/115.sh". If I do
trickle -s -u 5 sh /usr/local/115/115.sh, then the upload limit is not in effect.
The inside of /usr/local/115/115.sh is
#!/bin/sh
export LD_LIBRARY_PATH=/usr/local/115/lib:$LD_LIBRARY_PATH export PATH=/usr/local/115:$PATH
/bin/bash -c "exec -a $0 /usr/local/115/115 > /dev/null 2>&1" $0
I feel I need to put the trickle command inside the 115.sh. How exactly should I do it? Thanks
I tried
trickle -s -u 5 /bin/bash -c "exec -a $0 /usr/local/115/115 > /dev/null 2>&1" $0
/bin/bash -c "exec -a trickle -s -u 5 $0 /usr/local/115/115 > /dev/null 2>&1" $0
and
/bin/bash -c "exec -a $0 trickle -s -u 5 /usr/local/115/115 > /dev/null 2>&1" $0
but still the speed limit is not effective.
Related
We use our local repo in sources.list, and for 20.04 it required to add in apt.conf.d
Acquire::https::local_repo.local_host.com::Verify-Peer "false";
With Bash it works, as using,
sudo tee -a /etc/apt/apt.conf.d/80ssl-exceptions > /dev/null <<'EOF'
Acquire::https::local_repo.local_host.com::Verify-Peer "false";
EOF
But I don't find a solution to do it for Dockerfile.
I've tried it with different escape character/new line and so on, but always unsuccessful.
For example,
sudo tee -a /etc/apt/apt.conf.d/80ssl-exceptions > /dev/null <<'EOF' \
Acquire::https::local_repo.local_host.com::Verify-Peer "false"; \
EOF
Results - /bin/sh: 1: EOF: not found
To note that cat or echo is not an option, also adding those 3 line in a script is also not preferable.
If you only have one line to append then I wouldn't use a heredoc. It's simpler to use echo:
RUN echo 'Acquire::https::local_repo.local_host.com::Verify-Peer "false";' | \
sudo tee -a /etc/apt/apt.conf.d/80ssl-exceptions > /dev/null
Or cat:
RUN cat <<< 'Acquire::https::local_repo.local_host.com::Verify-Peer "false";' | \
sudo tee -a /etc/apt/apt.conf.d/80ssl-exceptions > /dev/null
Or send the string directly to sudo tee:
RUN sudo tee -a /etc/apt/apt.conf.d/80ssl-exceptions > /dev/null \
<<< 'Acquire::https::local_repo.local_host.com::Verify-Peer "false";'
Note that the latter two options may require you to also set SHELL /bin/bash since <<< is a bash-ism not available in plain sh.
I run a few scripts 1 by 1
cat 001.sh
sh /home/mysqldom/da-cron/f_mysqldom_nrd/5_change_nrd_tld.sh
sh /home/mysqldom/da-cron/f_mysqldom_nrd/5_proxy_removed.sh
sh /home/mysqldom/da-cron/f_mysqldom_nrd/6_sync_nrd.sh
The last script wont work... if I run manually it work very well...
the script is
cat 6_sync_nrd.sh
source /home/mysqldom/da-cron/var.sh
cd /home/mysqldom/da-cron/f_mysqldom_nrd/
mysql -u mysqldom_fnrd -p$mysqldom_fnrd_password -D mysqldom_fnrd -e "UPDATE \`$yesterday\` SET sync='$yesterday';"
mysql -u mysqldom_fnrd -p$mysqldom_fnrd_password -D mysqldom_fnrd -e "DELETE FROM \`$yesterday\` WHERE domain_name = 'domain_name';"
sed s/change_database/$yesterday/g update.conf > $yesterday.conf
/usr/share/logstash/bin/logstash -f $yesterday.conf --path.data /var/lib/logstash108
rm -rf nohup.out
The 6 has to be run after 5
any idea whats worn in it
Im trying to write a bash script that will curl a file and send it to my server over netcat then sleep (10) and send another file and sleep for 1hour then repeat all the process.
the first file is uploaded successfully but the second file : NO, i don't know what wrong with my code.
Ant help will be appreciated.
#!/bin/bash
file="curl -L mydomain.net/file.txt -o file.php"
file2="curl -L mydomain.net/file2.txt -o file2.php"
while true
do
if cat <(echo "${file}") | nc -u 120.0.0.1 4444 -w 1
echo -e "\e[92m[*][INFO] file1 uploaded"
sleep 10
then
cat <(echo "${file2}") | nc -u 120.0.0.1 4444 -w 1
echo -e "\e[91m[*][INFO] file2 uploaded"
sleep 3600
fi
done
$ ulimit -n
1024
$ /bin/sh -c ulimit -n
unlimited
Even if I specify the shell I am using:
$ echo $SHELL
/bin/bash
$ /bin/bash -c ulimit -n
unlimited
Why is ulimit not giving me the same value?
This happens because you're running ulimit without arguments. The -n is not part of the command being executed, and will instead become $0. The thing that's unlimited is therefore the max file size
Compare the output of:
bash -c 'echo hello' # says hello
bash -c echo hello # blank line
and then run:
bash -c 'ulimit -n'
I'm creating an automatic network configuration script and in it i have
#!/bin/bash
sudo rm /etc/default/ifplugd
sudo echo "INTERFACES=""
HOTPLUG_INTERFACES="wlan0 eth0"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"" > /etc/default/ifplugd
however on viewing /etc/default/ifplugd some of the quotes are missing
INTERFACES=
HOTPLUG_INTERFACES=wlan0 eth0
ARGS=-q -f -u0 -d10 -w -I
SUSPEND_ACTION=stop
How do I configure the script so it includes the quotes between the first and last echo ones?
How about:
sudo sh -c 'cat <<END >/etc/default/ifplugd
INTERFACES=""
HOTPLUG_INTERFACES="wlan0 eth0"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"
END
'
You don't need to explicitly rm, the > redirection will truncate the file before writing the new content.
You need to escape the " marks with a \ prefix, like this:
#!/bin/bash
sudo rm /etc/default/ifplugd
sudo echo "INTERFACES=\"\"
HOTPLUG_INTERFACES=\"wlan0 eth0\"
ARGS=\"-q -f -u0 -d10 -w -I\"
SUSPEND_ACTION=\"stop\"" > /etc/default/ifplugd
A heredoc provides an elegant solution:
sudo tee << EOF /etc/default/ifplugd
INTERFACES=""
HOTPLUG_INTERFACES="wlan0 eth0"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"
EOF
This way, you don't have to manually quote each and every "" around, and you are not removing the ifplugd file, so you won't need to reset permissions after creating it.