I'm trying to upload the following files and linksto iron.io:
After downloading the files from iron.io that were originally uploaded, I can see that the links are turned into these files
How do I maintain the links so that they are not turned into files in the process of uploading to iron.io.
Ideally, I can run this bash script on iron.io to solve for this:
rm libicudata.so.50 && ln -s libicudata.so.50.1.2 libicudata.so.50
rm libicui18n.so.50 && ln -s libicui18n.so.50.1.2 libicui18n.so.50
rm libicuio.so.50 && ln -s libicuio.so.50.1.2 libicuio.so.50
rm libicule.so.50 && ln -s libicule.so.50.1.2 libicule.so.50
rm libiculx.so.50 && ln -s libiculx.so.50.1.2 libiculx.so.50
rm libicutu.so.50 && ln -s libicutu.so.50.1.2 libicutu.so.50
rm libicuuc.so.50 && ln -s libicuuc.so.50.1.2 libicuuc.so.50
For reference, this is my worker:
# set the runtime language. Python workers use "python"
runtime "python"
# exec is the file that will be executed:
exec "test.py"
stack 'selenium'
remote
file "iron.json"
file "test.py"
dir '/Library/dataextract/'
I upload this worker with the following bash script:
iron_worker upload test
You can't "upload" a symlink. It's a symbolic link, there's no way to "send" it anywhere. You can create a tarball and upload that instead.
cd /path/to/the/files && tar cvf libs.tar *
Then on the receiving server, untar the files:
cd /path/to/the/files && tar xvf libs.tar
Assuming the symlinks are relative and pointing to files in the same directory, they will probably be successfully preserved. If they are absolute, they may be pointing to the wrong location.
Related
I am writing a bash script to do a account restore. The contents of the home dir is zipped up using this command.
sudo sh -c "cd /home/$username; zip -0 -FS -r -b /tmp /home/0-backup/users/$username.zip ."
This works as expected.
If the user requests a restore of their data, I am doing the following
sudo sh -c "cd /home/$username; rm -rf *"
Then
sudo -u $username unzip /home/0-backup/users/$username.zip -d /home/$username/
This works as expected.
However you can see the flaw in the delete statement, if the username is not set. We delete all users home dir. I have if statements that do the checking to make sure the username is there. I am looking for some advice on a better way to handle resetting the users account data that isn't so dangerous.
One thought I had was to delete the user account and then recreate it. Then do the restore. I think that this would be less risky. I am open to any suggestions.
Check the parameters first.
Then use && after cd so that it won't execute rm if the cd fails.
if [ -n "$username" ] && [ -d "/home/$username" ]
then
sudo sh -c "cd '/home/$username' && rm -rf * .[^.]*"
fi
I added .[^.]* in the rm command so it will delete dot-files as well. [^.] is needed to prevent it from deleting . (the user's directory) and .. (the /home directory).
I believe it should be straight forward but either I am having a bad day or I simply can't find what I am looking for.
Please help.
I need to run following commands in MAC Terminal in order to get rid of following entries:
sudo rm -Rf /Applications/Network\ Connect.app
sudo rm -Rf /Library/Frameworks/net.juniper.DSApplicationServices.framework
sudo rm -Rf /Library/Frameworks/net.juniper.DSCoreServices.framework
sudo rm -Rf /Library/Frameworks/net.juniper.DSNetworkDiagnostics.framework
sudo rm -Rf /Library/Internet\ Plug-ins/net.juniper.DSSafariExtensions.plugin
sudo rm -Rf /Library/Widgets/Network\ Connect.wdgt
sudo rm -Rf /usr/local/juniper
sudo rm -Rf /private/var/db/receipts/net.juniper.NetworkConnect.bom
sudo rm -Rf /private/var/db/receipts/net.juniper.NetworkConnect.plist
sudo rm -Rf ~/Library/Preferences/ncproxyd.plist
It does it's job but it's not exactly elegant. I was also thinking about providing this to my colleagues so I wanted to create some sort of .bat file for MAC.
I really spent about half day trying to figure it out but it doesn't work :(
Can somebody help me to create a .sh file or bash file which will do execute the commands above?
Create a script file, let's say it's called deletion.sh and add the lines: -
#!/bin/bash
rm -Rf /Applications/Network\ Connect.app
rm -Rf /Library/Frameworks/net.juniper.DSApplicationServices.framework
rm -Rf /Library/Frameworks/net.juniper.DSCoreServices.framework
rm -Rf /Library/Frameworks/net.juniper.DSNetworkDiagnostics.framework
rm -Rf /Library/Internet\ Plug-ins/net.juniper.DSSafariExtensions.plugin
rm -Rf /Library/Widgets/Network\ Connect.wdgt
rm -Rf /usr/local/juniper
rm -Rf /private/var/db/receipts/net.juniper.NetworkConnect.bom
rm -Rf /private/var/db/receipts/net.juniper.NetworkConnect.plist
rm -Rf ~/Library/Preferences/ncproxyd.plist
Then, in terminal you need to set the executable flag to the script: -
chmod +x deletion.sh
Note that the executable flag may be removed when the script is copied to another machine or network drive, so you may have to do that after copying.
Finally, you can call the script with sudo
sudo ./deletion.sh
If you want to create a batch file, you have one. That list of commands is your shell script. To execute it, just save hem into a file add the bash command to the front of that file's name:
$ bash commands_I_want_to_execute.txt
If you want to get fancy, you can put a shebang on the top and set the execution bit using chmod. That will make your script a real shell script.
However, in order for your shell script to be found, you need to either prefix it with a path, or put it in a directory that's included in your PATH. Here, I'll just prefix it:
$ chmod a+x commands_I_want_to_execute.txt # Suffix doesn't really matter. It's executable
$ ./commands_I_want_to_execute.txt # Now this will be executed
If you are really bothered by the suffix, change it with the mv command:
$ mv commands_I_want_to_execute.txt commands_I_want_to_execute.sh
NOTE: If you create a file with Text Edit, create it as a plain text file and not as a RTF file.
First I want to say that I don't really know what I should look for, here in Stack Overflow and what could be a good query for my problem.
In simple words I want to create a new directory and than do some file operations in it. But with the script that I have crafted I got always a file instead of a directory. It seems to be absolutely regardless how I stick the code together there is always the same result. I hope tat masses can help me with their knowledge.
Here is the script:
#!/bin/bash
DLURL=http://drubuntu.googlecode.com/git'
d7dir=/var/www/d7/'
dfsettings=/var/www/d7/sites/default/default.settings.php
settings=/var/www/d7/sites/default/settings.php
#settiing up drush
drush -y dl drush --destination=/usr/share;
#Download and set up drupal
cd /var/www/;
drush -y dl drupal;
mkdir "$d7dir"; #this is the line that always produces a file instead a directory
# regardless if it is replaced by the variable or entered as
# /var/www/d7
cd /var/www/drup*;
cp .htaccess .gitignore "$d7dir";
cp -r * "$d7dir";
cd "$d7dir";
rm -r /var/www/drup*;
mkdir "$d7dir"sites/default/files;
chmod 777 "$d7dir"sites/default/files;
cp "$dfsettings" "$settings";
chmod 777 "$settings";
chown $username:www-data /var/www/d7/.htaccess;
wget -O $d7dir"setupsite $DLURL/scripts/setupsite.sh; > /dev/null 2>&1
chmod +x /var/www/setupsite;
echo "Login Details following...";
read -sn 1 -p "Press any key to continue...";
bash "$d7dir"setupsite;
chown -Rh $username:www-data /var/www;
chmod 644 $d7dir".htaccess;
chmod 644"$settings";
chmod 644"$dfsettings";
exit
I hope someone got the reason for that.
There are many way to debug a shell-scripting.
Add set -x in your beginning script
Get the return value.
mkdir 'the-directory'
ret=$?
if test $ret -eq 0; then
echo 'Create success.'
else
echo 'Failed to create.'
fi
Set to verbose mode $ mkdir -v 'the-directory'
Try this command $ type mkdir, to checking mkdir command.
#!/bin/bash
mkdir /tmp
curl -O http://www.mucommander.com/download/nightly/mucommander-current.app.tar.gz /tmp/mucommander.tgz
tar -xvzf /tmp/mucommander.tgz */mucommander.app/*
cp -r /tmp/mucommander.app /Applications
rm -r /tmp
I'm trying to create a shell script to download and extract muCommander to my applications directory on a Mac.
I tried cd into the tmp dir, but then the script stops when I do that.
I can extract all using the -C argument, but the current tgz path is muCommander-0_9_0/mucommander.app, which could change on later builds, so I'm trying to keep it generic.
Can anyone give me pointers where I'm going wrong?
Thanks in advance.
Strip the first path component when you untar the archive, from tar(1):
--strip-components count
(x mode only) Remove the specified number of leading path ele-
ments. Pathnames with fewer elements will be silently skipped.
Note that the pathname is edited after checking inclusion/exclu-
sion patterns but before security checks.
Update
Here is a working bash example of how to, fairly generically, copy the contents of the tgz file to /Applications.
shopt -s nocaseglob
TMPDIR=/tmp
APP=mucommander
TMPAPPDIR=$TMPDIR/$APP
mkdir -p $TMPAPPDIR
curl -o $TMPDIR/$APP.tgz http://www.mucommander.com/download/nightly/mucommander-current.app.tar.gz
tar --strip-components=1 -xvzf $APP.tgz -C $TMPAPPDIR
mv $TMPAPPDIR/${APP}* /Applications
# rm -rf $TMPAPPDIR $TMPDIR/$APP
The rm command is commented out for now, verify that it does no harm before you use it.
The following will update your muCommander.
#for the safety, remove old temporary extraction from the /tmp
rm -rf /tmp/muCommander.app
#kill the running mucommander - you dont want replace the runnung app
ps -ef | grep ' /Applications/muCommander.app/' | grep -v grep | awk '{print $2}' | xargs kill
#download, extract, remove old, move new, open
#each command run only when the previous ended with success
curl http://www.mucommander.com/download/nightly/mucommander-current.app.tar.gz |\
tar -xzf - -C /tmp --strip-components=1 '*/muCommander.app' && \
rm -rf /Applications/muCommander.app && \
mv /tmp/muCommander.app /Applications && \
open /Applications/muCommander.app
Beware, after the '\' must following new line, and not any spaces...
I have this simple bash script that gets a copy from my dev server:
#!/bin/sh
DATE=`date +%Y-%m-%d_%H%M.%S`
BASEDIR="/var/www/db"
RELEASEDIR="$DATE";
RELEASEDIRFULL="$BASEDIR/releases/$RELEASEDIR"
mkdir -p "$RELEASEDIRFULL"
echo "Chdir to \"$RELEASEDIRFULL\""
cd "$RELEASEDIRFULL"
echo "Getting copy from dev"
ssh dev.example.tld "cd /tmp; cd /sites/db; tar -zcvp --exclude data --exclude scripts -f - *" | tar zxvpf -
ln -s /var/www/db/data data
ln -s /var/www/db/scripts scripts
cd $BASEDIR
rm htdocs; ln -s releases/$RELEASEDIR htdocs
Recently it stopped working properly with no apparent reason. It gets to the ssh line, executes it fine (files appear on live server) but does not proceed with ln commands. If I comment the ssh line out, ln lines will get executed properly.
UPDATE: I noticed that when I'm logged on as www-data and start the script, it completes as expected, without errors.
No time to check up the man page, but looks like your tar input is - * - all files + stdin? Are you meaning -- for suspension of further argument processing (if tar supports that)