Created
December 26, 2014 07:50
-
-
Save alexklibisz/97694dc363785446b610 to your computer and use it in GitHub Desktop.
Linux shell script that determines whether or not a Linux partition in a Windows/Linux dual-boot is being booted directly or through VirtualBox and mounts the data directories accordingly
This file contains 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 characters
#!/bin/bash | |
DIR="/media/alex/Data" | |
# init | |
# delete all of the directories that should be symlinked in the home directory | |
rm -rf /home/alex/Desktop | |
rm -rf /home/alex/Documents | |
rm -rf /home/alex/Pictures | |
rm -rf /home/alex/Videos | |
# delete and recreate the /media/alex/Data directory, try to mount the data partition there | |
rm -rf $DIR | |
mkdir $DIR | |
mount /dev/sda3 $DIR | |
df -h | |
# check if the directory is empty after mounting the data partiton | |
if [ "$(ls -A $DIR)" ]; then | |
# the directory is not empty, so we are booted directly into linux, symlink directories from the data partition | |
ln -s /media/alex/Data/Users/Alex/Desktop /home/alex/Desktop | |
ln -s /media/alex/Data/Users/Alex/Documents /home/alex/Documents | |
ln -s /media/alex/Data/Users/Alex/Pictures /home/alex/Pictures | |
ln -s /media/alex/Data/Users/Alex/Videos /home/alex/Videos | |
else | |
# the directory is empty, so we are in virtualbox, symlink directories mounted from virtualbox | |
ln -s /media/sf_Desktop/ /home/alex/Desktop | |
ln -s /media/sf_Documents/ /home/alex/Documents | |
ln -s /media/sf_Pictures/ /home/alex/Pictures | |
ln -s /media/sf_Videos/ /home/alex/Videos | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment