mostly done

This commit is contained in:
staticsafe 2012-01-05 13:19:14 -05:00
parent 93856e6bc7
commit e0473a7e4d
1 changed files with 63 additions and 6 deletions

View File

@ -1,11 +1,11 @@
#!/usr/bin/env python #!/usr/bin/env python
#Personal environment setup script #Personal environment setup script
#Dependencies - Supported distros, sudo
import os import os
from subprocess import call from subprocess import call
import platform import platform
import re
import urllib2 import urllib2
#global vars #global vars
@ -17,8 +17,64 @@ def rootcheck():
#rootcheck #rootcheck
uid = os.getuid() uid = os.getuid()
if uid != 0: if uid != 0:
print 'This script must be run as root or sudo if you have it!' print 'This script must be run with sudo if you have it!'
raise SystemExit raise SystemExit
else:
print 'Root check: PASSED!'
def urldownload(confurl = ""):
#Thanks PabloG from StackExchange for this little snippet
url = confurl
file_name = url.split('/')[-1]
u = urllib2.urlopen(url)
f = open(file_name, 'wb')
meta = u.info()
file_size = int(meta.getheaders("Content-Length")[0])
print "Downloading: %s Bytes: %s" % (file_name, file_size)
file_size_dl = 0
block_sz = 8192
while True:
buffer = u.read(block_sz)
if not buffer:
break
file_size_dl += len(buffer)
f.write(buffer)
status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size)
status = status + chr(8)*(len(status)+1)
print status,
f.close()
def confdownload():
urldownload(confurl = vimrcurl)
urldownload(confurl = zshrcurl)
urldownload(confurl = tmuxurl)
def envArch():
#Install relevant packagtes
installpackages = call("sudo pacman --noconfirm -S vim zsh tmux git subversion", shell=True)
#Get relevant dotfiles
confdownload()
def envFedora():
#Install relevant packages
installpackages = call ("sudo yum install -y vim zsh tmux git subversion", shell=True)
#Get relevant dotfiles
confdownload()
def envDebian():
#Install relevant packages
installpackages = call ("sudo apt-get install --assume-yes vim zsh tmux git subversion", shell=True)
#Get relevant dotfiles
confdownload()
def main(): def main():
#homedircheck #homedircheck
@ -29,17 +85,18 @@ def main():
os.chdir(homedir) os.chdir(homedir)
else: else:
print "Home directory check : PASSED!'" print "Home directory check : PASSED!'"
#distrocheck #distrocheck
userdistro = platform.linux_distribution() userdistro = platform.linux_distribution()
if userdistro[0] == "Fedora": if userdistro[0] == "Fedora":
envFedora():
elif userdistro[0] == "debian": elif userdistro[0] == "debian":
envDebian()
elif userdistro[0] == "Arch" or os.path.isfile("/etc/arch-release") == True: elif userdistro[0] == "Arch" or os.path.isfile("/etc/arch-release") == True:
envArch()
elif userdistro[0] == "Ubuntu": elif userdistro[0] == "Ubuntu":
envDebian()
else: else:
print "This script is not supported for your distro, exiting." print "This script is not supported for your distro, exiting."
raise SystemExit raise SystemExit