![]() Now login to the server and run the script as root." Scp -p "$SCRIPT" $RHOST:/$INSTALL_DIRĮcho "Done. Ssh $RHOST "umask 027 mkdir -p $INSTALL_DIR" I'd like to change my setup script from expecting root to using sudo, since we may want to share it with others and make it work on servers where root is not available (like Ubuntu).Įcho "Copying script '$'"Įcho "(You need to login (as root) 2 times.)" This function asked for root login to create a folder to put the script in and then copied the script.Īs this project has gone on, we've found that some software we'll need to use expects a "sudo" environment (rather than a root login) for its own setup script. ![]() This script started out as a quick, bad hack, but has slowly grown into a bigger, slightly less bad hack.īefore, my script had a built-in "bootstrap" function that made it easy for me to copy it from my development computer to the remote server where it would be used. I have a shell script to set up the environment and install a fairly complicated web application on a webserver. Mv "$filename" "/archive/location with spaces/" # I deliberately use paths with spaces to show how to handle themįor filename in "/source/location with spaces"/* do Use key-based authentication or read the username and password from the command line with sshfs. Sshfs -p $port $host:"/path/on/the/remote/host/" "/mnt/a b/remote/" (It's best to name variables with lowercase letters.). , it will be so much easier to handle this. But now, all work related to SFTP should be handled in a clear way byĪlso, when you use shell globbing and quotes, your code is more likely to have errors caused by things like spaces in filenames, etc. To the local archive if not, try again or do something else. To the remote location succeeded, only then To mount the remote share(s) as local path(s). The following approach may simplify things a lot:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |