Skip to content

Instantly share code, notes, and snippets.

@wemakefuture
Last active December 27, 2018 18:31
Show Gist options
  • Save wemakefuture/692f3e1bf08a7b2b33a73a8684600ece to your computer and use it in GitHub Desktop.
Save wemakefuture/692f3e1bf08a7b2b33a73a8684600ece to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "checking for folder"
if [ -d root/UpdateInstaPy/ ]
then
now=$(date +\%m_\%d_\%Y)
mkdir /root/UpdateInstaPy/$now
echo "created new Folder with name: $now"
cd /root/UpdateInstaPy/$now && git clone https://github.com/timgrossmann/InstaPy.git
latest_version=$(wget https://chromedriver.storage.googleapis.com/LATEST_RELEASE -O -)
wget https://chromedriver.storage.googleapis.com/${latest_version}/chromedriver_linux64.zip
unzip chromedriver_linux64
mv chromedriver /root/UpdateInstaPy/$now/InstaPy/assets/chromedriver
chmod +x /root/UpdateInstaPy/$now/InstaPy/assets/chromedriver
chmod 755 /root/UpdateInstaPy/$now/InstaPy/assets/chromedriver
rm chromedriver_linux64.zip
cd
cd /root/UpdateInstaPy/$now/InstaPy/ && pip install .
else
now=$(date +\%m_\%d_\%Y)
mkdir /root/UpdateInstaPy
mkdir /root/UpdateInstaPy/$now
echo "created new globalfolder UpdateInstaPy and subfolder with name: $now"
cd /root/UpdateInstaPy/$now && git clone https://github.com/timgrossmann/InstaPy.git
latest_version=$(wget https://chromedriver.storage.googleapis.com/LATEST_RELEASE -O -)
wget https://chromedriver.storage.googleapis.com/${latest_version}/chromedriver_linux64.zip
unzip chromedriver_linux64
mv chromedriver /root/UpdateInstaPy/$now/InstaPy/assets/chromedriver
chmod +x /root/UpdateInstaPy/$now/InstaPy/assets/chromedriver
chmod 755 /root/UpdateInstaPy/$now/InstaPy/assets/chromedriver
rm chromedriver_linux64.zip
cd
cd /root/UpdateInstaPy/$now/InstaPy/ && pip install .
fi
cd
cp -v /root/UpdateInstaPy/*.py /root/UpdateInstaPy/$(date +\%m_\%d_\%Y)/InstaPy
cd
rm -rf /root/UpdateInstaPy/$(date -d 'yesterday' +\%m_\%d_\%Y)
echo "all done have fun"
@wemakefuture
Copy link
Author

wemakefuture commented Dec 26, 2018

add the auto.sh to cron and set up your cronjob like this example: 32 * * * * cd UpdateInstaPy/$(date +\%m_\%d_\%Y)/InstaPy/ && python3 quickstart.py
change root in paths to your user

@wemakefuture
Copy link
Author

#!/bin/bash
echo "checking for folder"
if [ -d root/UpdateInstaPy/ ]
then
now=$(date +\%m_\%d_\%Y)
mkdir /root/UpdateInstaPy/$now
echo "created new Folder with name: $now"
cd /root/UpdateInstaPy/$now && git clone https://github.com/timgrossmann/InstaPy.git
latest_version=$(wget https://chromedriver.storage.googleapis.com/LATEST_RELEASE -O -)
wget https://chromedriver.storage.googleapis.com/${latest_version}/chromedriver_linux64.zip
unzip chromedriver_linux64
mv chromedriver /root/UpdateInstaPy/$now/InstaPy/assets/chromedriver
chmod +x /root/UpdateInstaPy/$now/InstaPy/assets/chromedriver
chmod 755 /root/UpdateInstaPy/$now/InstaPy/assets/chromedriver
rm chromedriver_linux64.zip
else
now=$(date +\%m_\%d_\%Y)
mkdir /root/UpdateInstaPy
mkdir /root/UpdateInstaPy/$now
echo "created new globalfolder UpdateInstaPy and subfolder with name: $now"
cd /root/UpdateInstaPy/$now && git clone https://github.com/timgrossmann/InstaPy.git
latest_version=$(wget https://chromedriver.storage.googleapis.com/LATEST_RELEASE -O -)
wget https://chromedriver.storage.googleapis.com/${latest_version}/chromedriver_linux64.zip
unzip chromedriver_linux64
mv chromedriver /root/UpdateInstaPy/$now/InstaPy/assets/chromedriver
chmod +x /root/UpdateInstaPy/$now/InstaPy/assets/chromedriver
chmod 755 /root/UpdateInstaPy/$now/InstaPy/assets/chromedriver
rm chromedriver_linux64.zip
fi

echo "pip install and moving files"
if  [ -d root/UpdateInstaPy/ ]
then
now=$(date +\%m_\%d_\%Y)
cd root/UpdateInstaPy/$now/InstaPy/ && pip install .
cp root/UpdateInstaPy/*.py root/UpdateInstaPy/$now/InstaPy/
fi

echo
if [ -d root/UpdateInstaPy/ ]
then
"Deleting old folders"
now=$(date +\%m_\%d_\%Y)
find root/UpdateInstaPy -mindepth 1 ! -regex '^root/UpdateInstaPy/$now\(/.*\)?' -delete
else
echo "not deleting"
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment