I threw one together for you based on the comment left from @steeldriver. This is just a command line script allowing multiple input on the command line. It uses getopts
for multiple options as well as adding in nohup command &
for moving the scripts to the background so that the next case can run.
For further help, search the internet for bash getopts. There's so much to learn out there and you can make incredible scripts to do whatever you want.
The Script:
#!/bin/bash
#Set name
NAME=$(basename $0)
#Set option choices
OPTS="h12345"
PUSAGE=""
#This is how to use the script
usage="
Hello, "$USER". This script will allow you to start the following.
You can run as many as you like starting with a `-`. Example below.
Usage: ${NAME} [OPTIONS]
Options are:
-h Show this message.
-1. Claymore ZEC v12.6
-2. Claymore ETH & SIA v10
-3. Claymore ETH v10
-4. XMRIG ETN v2.4.4 //etn-pool.proxpool
-5. XMRIG ETN v2.4.4 //pool.etn.spacepools.org
Example:
${NAME} -135
"
#Run script
while getopts :${OPTS} i ; do
case $i in
1)
echo "Starting to mine ZEC."
cd ~/Downloads/claymore.s.Zcash.v12.6/
nohup ./mine.sh & 2>&1>/dev/null;;
2)
echo "Starting to mine ETH & SIA."
cd ~/Downloads/claymore.dualminer.v10_ETHSIA/
nohup ./mine.sh & 2>&1>/dev/null;;
3)
echo "Starting to mine ETH."
cd ~/Downloads/claymore.dualminer.v10_ETHSIA/
nohup ./mineETH.sh & 2>&1>/dev/null;;
4)
echo "Starting to mine ETN."
cd ~/Downloads/Electroneum/XMRIG/build/
sudo sysctl -w vm.nr_hugepages=128
clear
cat /proc/meminfo | grep Huge
nohup ./mine.sh & 2>&1>/dev/null;;
5)
echo "Starting to mine ETN."
cd ~/Downloads/Electroneum/XMRIG/build/
sudo sysctl -w vm.nr_hugepages=128
clear
cat /proc/meminfo | grep Huge
nohup ./mine_space.sh & 2>&1>/dev/null;;
h | \?) PUSAGE=1;;
esac
done
#Show help based on selection
if [ ${PUSAGE} ]; then
echo "${usage}"
exit 0
fi
#Check for input if none show help.
if [[ $1 == "" ]]; then
echo "${usage}"
exit 0
fi
Now, if you run the script with nothing after or a -h
for help, the following appears. I named my script askhelp.bsh
just as an example.
~$ ./askhelp.bsh
Hello, terrance. This script will allow you to start the following.
You can run as many as you like separated by spaces and dashes. Example below.
Usage: askhelp.bsh [OPTIONS]
Options are:
-h Show this message.
-1. Claymore ZEC v12.6
-2. Claymore ETH & SIA v10
-3. Claymore ETH v10
-4. XMRIG ETN v2.4.4 //etn-pool.proxpool
-5. XMRIG ETN v2.4.4 //pool.etn.spacepools.org
Example:
askhelp.bsh -135
Then in my test script I made it so that it echoes the lines to show that they are running.
Examples:
~$ ./askhelp.bsh -135
Starting Option 1
Starting to mine ZEC.
cd ~/Downloads/claymore.s.Zcash.v12.6/
nohup ./mine.sh & 2>&1>/dev/null
Starting Option 3
Starting to mine ETH.
cd ~/Downloads/claymore.dualminer.v10_ETHSIA/
nohup ./mineETH.sh & 2>&1>/dev/null
Starting Option 5
Starting to mine ETN.
cd ~/Downloads/Electroneum/XMRIG/build/
sudo sysctl -w vm.nr_hugepages=128
clear
cat /proc/meminfo | grep Huge
nohup ./mine_space.sh & 2>&1>/dev/null
Another example:
~$ ./askhelp.bsh -24
Starting Option 2
Starting to mine ETH & SIA.
cd ~/Downloads/claymore.dualminer.v10_ETHSIA/
nohup ./mine.sh & 2>&1>/dev/null
Starting Option 4
Starting to mine ETN.
cd ~/Downloads/Electroneum/XMRIG/build/
sudo sysctl -w vm.nr_hugepages=128
clear
cat /proc/meminfo | grep Huge
nohup ./mine.sh & 2>&1>/dev/null
New script from request:
This script should open a new gnome-terminal
for each choice made for tracking back. The commands are done for gnome-terminal
. If you decide to use a different terminal, make sure you make the appropriate changes to the command in each case statement.
#!/bin/bash
#Set name
NAME=$(basename $0)
#Set option choices
OPTS="h12345"
PUSAGE=""
#This is how to use the script
usage="
Hello, "$USER". This script will allow you to start the following.
You can run as many as you like starting with a `-`. Example below.
Usage: ${NAME} [OPTIONS]
Options are:
-h Show this message.
-1. Claymore ZEC v12.6
-2. Claymore ETH & SIA v10
-3. Claymore ETH v10
-4. XMRIG ETN v2.4.4 //etn-pool.proxpool
-5. XMRIG ETN v2.4.4 //pool.etn.spacepools.org
Example:
${NAME} -135
"
#Run script
while getopts :${OPTS} i ; do
case $i in
1)
gnome-terminal -x bash -c 'echo "Starting to mine ZEC."; cd ~/Downloads/claymore.s.Zcash.v12.6/; ./mine.sh';;
2)
gnome-terminal -x bash -c 'echo "Starting to mine ETH & SIA."; cd ~/Downloads/claymore.dualminer.v10_ETHSIA/; ./mine.sh';;
3)
gnome-terminal -x bash -c 'echo "Starting to mine ETH."; cd ~/Downloads/claymore.dualminer.v10_ETHSIA/; ./mineETH.sh';;
4)
gnome-terminal -x bash -c 'echo "Starting to mine ETN."; cd ~/Downloads/Electroneum/XMRIG/build/; sudo sysctl -w vm.nr_hugepages=128; clear; cat /proc/meminfo | grep Huge; ./mine.sh';;
5)
gnome-terminal -x bash -c 'echo "Starting to mine ETN."; cd ~/Downloads/Electroneum/XMRIG/build/; sudo sysctl -w vm.nr_hugepages=128; clear; cat /proc/meminfo | grep Huge; ./mine_space.sh';;
h | \?) PUSAGE=1;;
esac
done
#Show help based on selection
if [ ${PUSAGE} ]; then
echo "${usage}"
exit 0
fi
#Check for input if none show help.
if [[ $1 == "" ]]; then
echo "${usage}"
exit 0
fi
Hope this helps!
case
in aselect
- see How can I create a select menu in a shell script? for an example – steeldriver Jan 22 '18 at 14:06