cleanup and adding checks

This commit is contained in:
Sadiq Saif 2012-01-06 00:50:48 -05:00
parent 02bba521c9
commit 3f0860d16f
1 changed files with 38 additions and 17 deletions

View File

@ -48,26 +48,49 @@ def urldownload(confurl = ""):
print status, print status,
f.close() f.close()
def confdownload(): def checksandactions():
urldownload(confurl = vimrcurl) #vars for various conf files and dirs
urldownload(confurl = zshrcurl) vimrcdir = os.path.join(os.environ['HOME'], ".vimrc")
urldownload(confurl = tmuxurl) zshrcdir = os.path.join(os.environ['HOME'], ".zshrc")
urldownload(confurl = vimdirurl) tmuxconfdir = os.path.join(os.environ['HOME'], ".tmux.conf")
vimdir = os.path.join(os.environ['HOME'], ".vim")
usershell = os.getenv('SHELL')
#checks to prevent clobbering
if os.path.isfile(vimrcdir) == True:
print ".vimrc already exists, skipping download!"
else:
urldownload(confurl = vimrcurl)
if os.path.isfile(zshrcdir) == True:
print ".zshrc already exists, skipping download!"
else:
urldownload(confurl = zshrcurl)
if os.path.isfile(tmuxconfdir) == True:
print ".tmux.conf already exists, skipping download!"
else:
urldownload(confurl = tmuxurl)
if os.path.isdir(vimdir) == True:
print ".vim dir already exists, skipping download!"
else:
urldownload(confurl = vimdirurl)
untar = call("tar xvf vimdir.tar.bz2", shell = True) untar = call("tar xvf vimdir.tar.bz2", shell = True)
def defaultshell(): if usershell = "/bin/zsh":
print "Your default shell is already zsh! Skipping."
else:
print "Setting default shell for this user to zsh! Log out and log back in to see changes." print "Setting default shell for this user to zsh! Log out and log back in to see changes."
setzsh = call("chsh -s $(which zsh)", shell = True) setzsh = call("chsh -s $(which zsh)", shell = True)
def envArch(): def envArch():
sudocheck() sudocheck()
#Install relevant packagtes #Install relevant packages
installpackages = call("sudo pacman --noconfirm -S vim zsh tmux git subversion", shell=True) installpackages = call("sudo pacman --noconfirm -S vim zsh tmux git subversion", shell=True)
#Get relevant dotfiles #Get relevant dotfiles
confdownload() checksandactions()
defaultshell()
def envFedora(): def envFedora():
sudocheck() sudocheck()
@ -75,8 +98,7 @@ def envFedora():
installpackages = call ("sudo yum install -y vim zsh tmux git subversion", shell=True) installpackages = call ("sudo yum install -y vim zsh tmux git subversion", shell=True)
#Get relevant dotfiles #Get relevant dotfiles
confdownload() checksandactions()
defaultshell()
def envDebian(): def envDebian():
sudocheck() sudocheck()
@ -84,8 +106,7 @@ def envDebian():
installpackages = call ("sudo apt-get install --assume-yes vim zsh tmux git subversion", shell=True) installpackages = call ("sudo apt-get install --assume-yes vim zsh tmux git subversion", shell=True)
#Get relevant dotfiles #Get relevant dotfiles
confdownload() checksandactions()
defaultshell()
def main(): def main():
#homedircheck #homedircheck