-
-
Save apeixinho/1184627ba3271c972f6b9fa4d80f9cb3 to your computer and use it in GitHub Desktop.
Revisions
-
eladc renamed this gist
Mar 28, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
eladc revised this gist
Mar 28, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -151,10 +151,10 @@ chown $auser:$auser $uhome/Box ## echo "Done." echo "===========================================================" echo " Re-login to apply the changes: su - $auser " echo " Then Mount your Box folder by accessing " echo " /media/$auser@box from your file manager. " echo " a shortcut was created at /home/$auser/Box " echo "===========================================================" echo " a pre-configured script for rsync is at " echo " $uhome/.boxsync " -
eladc revised this gist
Mar 28, 2015 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ #!/bin/bash ## davfs2 installation and Box.com account configuration script for Linux ## Tested on Ubuntu, Fedora and OpenSuse ## Update 1.032615 ## This script must be run as root -
eladc revised this gist
Mar 28, 2015 . 2 changed files with 164 additions and 136 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,136 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,164 @@ #!/bin/bash ## davfs2 installation and Box.com account configuration script. ## Update 1.032615 ## This script must be run as root if [ ! $UID = 0 ]; then echo "This script needs super user privileges to run" echo "run it againg using sudo or login as root" exit 1 fi TTY=$(tty | sed -e 's:/dev/::') ## get current user: auser=$(w | grep $TTY | awk {'print $1'}) uhome=/home/$auser ## Remove option: if [ "$1" = '-r' ]; then echo "Removing credentials.." echo > "$uhome/.davfs2/secrets" echo "Removing mount point.." sed -i "/$auser@box/d" /etc/fstab echo "Removing symlink.." unlink /home/$auser/Box echo "Done. Exiting.." exit 0 elif [ -z "$1" ]; then : else echo "Usage:" echo "box-linux | Configure a Box account" echo "box-linux -r | Remove Box configuration" exit 1 fi ## determine OS type and install davfs2: os_type() { if [ -f /usr/bin/yum ]; then ## RH based distros yum -y install fuse-davfs2 davfs2 ## Double check if davfs2 was installed (for some RH based systems): if [ ! -d /etc/davfs2 ]; then echo "ERROR: davfs2 was not found." echo "Exiting without making any changes." exit 1 fi elif [ -f /usr/bin/dpkg ]; then ## Debian based distros apt-get -y install davfs2 dpkg-reconfigure davfs2 elif [ -f /usr/bin/zypper ]; then ## openSuse zypper ar -G http://download.opensuse.org/repositories/filesystems/openSUSE_Factory /openSUSE_Factory-filesystems zypper -n install davfs2 fi } echo "===========================================================" echo " This script will install davfs2" echo " and create a local mount point " echo " for your Box.com account." echo " **Choose Yes if asked to allow users to mount WebDAV** " echo "===========================================================" echo "" echo -n "Proceed with the installation? [Y/n]: " read -p "$1" STARTINSTALL if [ ! "$STARTINSTALL" == "Y" ]; then echo "Installation aborted." exit 1 else : fi ## user input: echo "Please enter your Email address: " read -p "$1" EMAIL echo -n "Please enter your Box password: " read -s PASSWORD echo "" echo "===========================================================" ## check if davfs2 is installed: if [ -d /etc/davfs2 ]; then : else os_type fi ## check if Box dir exists in users' Home: if [ -d /home/$auser/Box ]; then echo -n "Box already exists, would you like to update your login details? [Y\n]: " read ANSWER if [ ! "$ANSWER" == "Y" ]; then echo "Nothing to do. Exiting.." exit 1 else echo "https://dav.box.com/dav $EMAIL $PASSWORD" > $uhome/.davfs2/secrets echo "Done. Exiting.." exit 0 fi else ## add user the davfs2 group: echo "Adding $auser to davfs2 group.." usermod -a -G davfs2 $auser ## create folders: su - $auser -c "mkdir $uhome/.davfs2" mkdir /media/$auser@box ## write conf files: echo "writing configuration.." echo "dav_group davfs2" > /etc/davfs2/davfs2.conf echo "use_locks 0" >> /etc/davfs2/davfs2.conf if [ -f /etc/lsb-release ]; then if grep --quiet Ubuntu /etc/lsb-release ; then echo "#ignore_home kernoops" >> /etc/davfs2/davfs2.conf fi fi echo "https://dav.box.com/dav $EMAIL $PASSWORD" > $uhome/.davfs2/secrets chown $auser:$auser $uhome/.davfs2/secrets chmod 600 $uhome/.davfs2/secrets ## write mount point to fstab: if grep --quiet /media/$auser@box /etc/fstab ; then : else echo "## Box" >> /etc/fstab echo "https://dav.box.com/dav /media/$auser@box davfs _netdev,defaults,rw,users,noauto 0 0" >> /etc/fstab fi fi ## create rsync script if [ -f $uhome/.boxsync ]; then : else echo "#!/bin/bash" > $uhome/.boxsync echo "if grep --quiet box /etc/mtab ; then" >> $uhome/.boxsync echo " :" >> $uhome/.boxsync echo "else" >> $uhome/.boxsync echo " mount /media/$auser@box" >> $uhome/.boxsync echo "fi" >> $uhome/.boxsync echo "rsync -au /source /media/$auser@box" >> $uhome/.boxsync fi chown $auser:$auser $uhome/.boxsync chmod +x $uhome/.boxsync ## Create a symlink ln -s /media/$auser@box $uhome/Box chown $auser:$auser $uhome/Box ## echo "Done." echo "===========================================================" echo " Mount your Box folder by accessing " echo " /media/$auser@box from your file manager. " echo " a shortcut was created at /home/$auser/Box " echo " re-login to apply the changes: su - $auser " echo "===========================================================" echo " a pre-configured script for rsync is at " echo " $uhome/.boxsync " echo " edit the source/destination path to suit your needs " echo "===========================================================" exit 0 -
eladc revised this gist
Apr 14, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ echo "===========================================================" echo "" echo "Your local copy of Box will be at '$uhome/Box'" echo -n "Proceed with the installation? [Y/n]: " read -p STARTINSTALL if [ ! "$STARTINSTALL" == "Y" ]; then echo "Installation aborted." -
eladc revised this gist
Apr 14, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,7 +39,7 @@ fi ## user input: echo "Please enter your Box username: " read -p EMAIL echo -n "Please enter your Box password: " read -s PASSWORD echo "" -
eladc revised this gist
Apr 13, 2014 . 1 changed file with 13 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -50,7 +50,7 @@ if [ -d /etc/davfs2 ]; then : else os_type ## double check if davfs2 was installed (for some RH based systems): if [ -d /etc/davfs2 ]; then : else @@ -82,6 +82,10 @@ else ## write conf files: echo "dav_group davfs2" > /etc/davfs2/davfs2.conf echo "use_locks 0" >> /etc/davfs2/davfs2.conf ## add extra parameter for Ubuntu: if grep --quiet Ubuntu /etc/lsb-release ; then echo "ignore_home krenoops" >> /etc/davfs2/davfs2.conf fi echo "https://dav.box.com/dav $EMAIL $PASSWORD" > $uhome/.davfs2/secrets chown $auser:$auser $uhome/.davfs2/secrets chmod 600 $uhome/.davfs2/secrets @@ -93,7 +97,6 @@ else fi fi ## create a script & a cron job: function flock_cron() { su - $auser -c "touch $uhome/.box_rsync" @@ -119,13 +122,15 @@ else flock_cron fi ## echo "Done." echo "===========================================================" echo "Your local copy of Box is at '$uhome/Box'" echo "Auto sync with Box.com will occur on the 0th minute of every hour." echo "Finalize the installation manually by executing this command as $auser: (NOT as root)" echo "$ exec su -l $auser" echo "To sync your Box folder manually run:" echo "$ ./.box_rsync" echo "===========================================================" exit 0 -
eladc revised this gist
Apr 13, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,7 @@ function os_type() { yum -y install fuse-davfs2 davfs2 rsync elif [ -f /usr/bin/dpkg ]; then apt-get -y install davfs2 rsync dpkg-reconfigure davfs2 fi } @@ -124,6 +125,7 @@ su - $auser -c "$uhome/.box_rsync" echo "===========================================================" echo "Your local copy of Box is at '$uhome/Box'" echo "Synchronizing with Box.com will occure on the 0th minute of every hour." echo " echo "===========================================================" echo "Done. Exiting.." exit 0 -
eladc revised this gist
Apr 12, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/bash ## davfs2 & rsync installation script. As tested on Debian Testing - Kernel 3.10.7 ## rsync is used to prevent the file manager from freezing up when handling files on the dav mount point. ## run as root or using sudo. ## get current tty: TTY=$(tty | sed -e 's:/dev/::') -
eladc created this gist
Apr 12, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,129 @@ #!/bin/bash ## davfs2 & rsync installation script. As tested on Debian Testing - Kernel 3.10.7 ## rsync is used to prevent the file manager from freezing up when handling files on the dav mount point. ## This script must be run as root ## get current tty: TTY=$(tty | sed -e 's:/dev/::') ## get current user: auser=$(w | grep $TTY | awk {'print $1'}) uhome=/home/$auser ## determine OS type and install davfs2 & Rsync: function os_type() { if [ -f /usr/bin/yum ]; then yum -y install fuse-davfs2 davfs2 rsync elif [ -f /usr/bin/dpkg ]; then apt-get -y install davfs2 rsync fi } echo "===========================================================" echo " This script will install davfs2 & rsync" echo " and create a local mirror " echo " of your Box.com account." echo "===========================================================" echo "" echo "Your local copy of Box will be at '$uhome/Box'" echo -n "Proceed with the installation? [Y/n]: " read -p "$1" STARTINSTALL if [ ! "$STARTINSTALL" == "Y" ]; then echo "Installation aborted." exit 1 else : fi ## user input: echo "Please enter your Box username: " read -p "$1" EMAIL echo -n "Please enter your Box password: " read -s PASSWORD echo "" echo "===========================================================" ## check if davfs2 is installed: if [ -d /etc/davfs2 ]; then : else os_type ## check if davfs2 was installed (for some RH based systems): if [ -d /etc/davfs2 ]; then : else echo "ERROR: davfs2 was not found." echo "Exiting without making any changes." exit 1 fi fi ## check if Box dir exists in users' Home: if [ -d /home/$auser/Box ]; then echo -n "Box already exists, would you like to update your login details? [Y\n]: " read ANSWER if [ ! "$ANSWER" == "Y" ]; then echo "Nothing to do. Exiting.." exit 1 else echo "https://dav.box.com/dav $EMAIL $PASSWORD" > $uhome/.davfs2/secrets echo "Done. Exiting.." exit 0 fi else ## add user the davfs2 group: usermod -a -G davfs2 $auser ## create folders: su - $auser -c "mkdir $uhome/Box" su - $auser -c "mkdir $uhome/.davfs2" mkdir /media/$auser@box ## write conf files: echo "dav_group davfs2" > /etc/davfs2/davfs2.conf echo "use_locks 0" >> /etc/davfs2/davfs2.conf echo "https://dav.box.com/dav $EMAIL $PASSWORD" > $uhome/.davfs2/secrets chown $auser:$auser $uhome/.davfs2/secrets chmod 600 $uhome/.davfs2/secrets ## write mount point to fstab: if grep --quiet /media/$auser@box /etc/fstab ; then : else echo "https://dav.box.com/dav /media/$auser@box davfs _netdev,defaults,rw,users,noauto 0 0" >> /etc/fstab fi fi ## create a script & a cron job: function flock_cron() { su - $auser -c "touch $uhome/.box_rsync" echo "#!/bin/bash" > $uhome/.box_rsync echo "if grep -q /media/$auser@box /proc/mounts ; then" >> $uhome/.box_rsync echo " :" >> $uhome/.box_rsync echo "else" >> $uhome/.box_rsync echo " mount /media/$auser@box" >> $uhome/.box_rsync echo "fi" >> $uhome/.box_rsync echo "flock -n /var/lock/my_rsync_lock rsync -aur $uhome/Box/ /media/$auser@box/" >> $uhome/.box_rsync echo "flock -n /var/lock/my_rsync_lock rsync -aur /media/$auser@box/ $uhome/Box/ " >> $uhome/.box_rsync chmod 500 $uhome/.box_rsync crontab -l -u $auser > usercron echo "0 * * * * $uhome/.box_rsync" >> usercron crontab -u $auser usercron rm usercron } ## rsync: if [ -f $uhome/.box_rsync ]; then : else flock_cron fi ## echo "Synchronizing with Box for the first time." echo "Please wait, this might take a while..." su - $auser -c "$uhome/.box_rsync" echo "===========================================================" echo "Your local copy of Box is at '$uhome/Box'" echo "Synchronizing with Box.com will occure on the 0th minute of every hour." echo "===========================================================" echo "Done. Exiting.." exit 0