Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Help 

[SOLVED] I need help with a simple bash script

Im tired of the effort it takes to script new clients for my vpn server, and since my ip changes weekly and i have a lot of people to make clients for, i need an easier way to do this.
Essentially i need my script to accept an input, so like “./myscript XXX” and have it do the following things
$ cd openvpn-ca/
$ source vars
$ ./build-key XXX
$ cd ~client-configs/
$ ./makeconfig.sh XXX
$ cd files/
$ sudo cp XXX /home/ftpserver/ftp/files/
(That last location is where i pull the client files from on my phone so i can send them to people by email and such)
It should be simple but im new to scripting so i dont know how to go about this... i can do the
echo “mypassword” | sudo -S cp
Too to make it easier but whatever works. Thanks for reading if you did lol
___________________________________________________________

update since none of you helped ya boy out
this is what I did and it worked and i couldnt find any tutorials on google for what I needed specifically I just got lucky with some educated guesses but here it is
Code
#!/bin/bash
echo "Client name: "
read clientname
cd openvpn-ca/
source vars
~/openvpn-ca/./build-key $clientname
~/client-configs/./make_config.sh $clientname
echo mypassword | sudo -S cp ~/client-configs/files/$clientname.ovpn /home/ftpserver/ftp/files/
I was amazed when i did the .../files/$clientname.ovpn and it works and actually creates the ovpn file and copies it to the directory I need so i can use the ftp app on my phone and send it to people through airdrop and email and such.
the echo mypassword | sudo -S line lets you run commands that require sudo privileges without having to enter your password, since it echos your password for you. this is unsecure and a bad idea since it stores your password in plain text in the script, but if you leave your computer locked and secure and such then you will be fine. the average user wont know what theyre looking for and as long as nobody hacks you then there is no worries. I know im secure on my network and computer end so its safe for me to do that, but keep the risk in mind.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Help] by rjusticemiSep 21, 2025 10:25 PM 1 101 Sep 21, 2025 10:25 PM
Last Post: DNA
by HackersJun 4, 2024 11:18 AM 12 320 Jun 4, 2024 11:18 AM
Last Post: Hackers
by Leroy Jethro GibbsApr 10, 2017 02:39 AM 6 205 Apr 10, 2017 02:39 AM
Last Post: Leroy Jethro Gibbs