Skip to content

Instantly share code, notes, and snippets.

@SimonTod
Last active March 24, 2017 10:04
Show Gist options
  • Save SimonTod/b74a0636bb1c10fcc76cf6366e7721c0 to your computer and use it in GitHub Desktop.
Save SimonTod/b74a0636bb1c10fcc76cf6366e7721c0 to your computer and use it in GitHub Desktop.
#!/bin.bash
# this script is to be executed as a sudo user / NOT ROOT / don't use sudo command
# I recommand using it on a clean server and dedicate it to this task
# simply type this :
# bash storj-amazon.sh
# Before executing, you should have
# - an Amazon account which subscribed to the Amazon Cloud Drive offer
# - a wallet adress on Counterwallet.io
# the script has been tested on : Debian 8.6 / Ubuntu 14.04
# it does not work on : Ubuntu 16.04
sudo apt update
sudo apt upgrade -y
#installing packages
sudo apt-get install python python3 python3-pip build-essential samba fuse libfuse2 git curl apache2 php5 unzip wget -y
sudo curl -o /usr/local/bin/n https://raw.githubusercontent.com/visionmedia/n/master/bin/n
sudo chmod +x /usr/local/bin/n
sudo n latest
sudo chmod -R 777 /usr/local/
sudo npm install --global storjshare-daemon
sudo addgroup $USER fuse
if [ "$(grep -Ei 'debian' /etc/*release)" ]; then
sudo apt remove python3-pip -y
easy_install3 pip
fi
sudo pip3 install --upgrade git+https://github.com/yadayada/acd_cli.git
#configuring acd_cli
if [ ! -f ~/.cache/acd_cli/oauth_data ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "! Visit the webpage https://tensile-runway-92512.appspot.com/, connect to your Amazon Cloud Drive account, then open the output file !"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Copy the access_token (without the '\"')"
read access_token
echo "Copy the expires_in"
read expires_in
echo "Copy the refresh_token (without the '\"')"
read refresh_token
mkdir -p ~/.cache/acd_cli
echo -e "{\n \"access_token\": \"$access_token\",\n \"expires_in\": $expires_in,\n \"refresh_token\": \"$refresh_token\",\n \"token_type\": \"bearer\"\n}" > ~/.cache/acd_cli/oauth_data
fi
acd_cli sync
sudo mkdir -p /media/amazon
sudo chown $USER:$USER /media/amazon
if [ ! "$(ls -A /media/amazon)" ]; then
acd_cli mount /media/amazon
fi
mkdir -p /media/amazon/storj
if [ -d /media/amazon/storj/config ]
then
config_exists=true
else
config_exists=false
mkdir -p /media/amazon/storj/config
fi
mkdir -p /media/amazon/storj/logs
mkdir -p /media/amazon/storj/nodes
#configuring storjshare daemon
storjshare-daemon
sleep 10
if [ "$config_exists" = false ]; then
echo "Please enter your counterwallet.io wallet adress"
read wallet
echo "How many nodes do you want to create ?"
read nodes
echo "What size do you want for your nodes ? (in GB or TB / ex: 100GB or 1TB)"
read size
port=3000
for i in $(seq 1 $nodes)
do
if [ $i -lt 10 ]
then
num="0$i"
else
num="$i"
fi
mkdir -p /media/amazon/storj/nodes/$num
port=$(($port + 1))
storjshare-create --sjcx $wallet --storage /media/amazon/storj/nodes/$num --size $size --outfile /media/amazon/storj/config/$num.json --logfile /media/amazon/storj/logs/$num.log --rpcport $port --noedit
done
fi
for config_file in $(ls /media/amazon/storj/config)
do
storjshare-start --config /media/amazon/storj/config/$config_file
sleep 10
done
#configuring ez server monitor
read -p "Do you want the script to configure an eZ Server Monitor? This website will be available at http://<your ip adress>. only Y key will let you continue (Y/c) " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
wget https://www.ezservermonitor.com/esm-web/downloads/version/2.5 -O ~/ezservermonitor-web_2.5.zip
unzip ~/ezservermonitor-web_2.5.zip -d ~/
sudo mv /var/www/html/index.html /var/www/html/index.html.sav
sudo mv ~/eZServerMonitor-2.5/* /var/www/html
rm ~/ezservermonitor-web_2.5.zip
rmdir ~/eZServerMonitor-2.5
fi
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "! !"
echo "! Here you go ! It should be all good now !"
echo "! Use the next command to help you with storjshare from now on !"
echo "! > storjshare -h !"
echo "! You can have a quick look at what is going on whit this command !"
echo "! > storjshare-status !"
echo "! !"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment