Пример #1
0
def addShare(share, group=None, description=None, public=False) :
  debugOutput("Adding Samba share '%s'" % (share))
 
  if not group : group = groupNameFromShare(share)

  sharePath = os.path.join(SAMBA_SHARES_PATH, share)
 
  if share in getShares():
    if not smartbox.options.testRun :
      interface.abort("The share '%s' exists or has been defined already" % sharePath)
 
  if group not in system.readFromFile("/etc/group") :
    system.addGroup(group)
 
  if not os.path.exists(sharePath) :
    system.run("""mkdir -p "%s" """ % sharePath, exitOnFail = False)
  system.run("""chgrp %s "%s" """ % (group, sharePath))
  system.run("""chmod 6770 "%s" """ % sharePath)

  shareConfig = _createShareConfig(share, sharePath, group, description)
  
  sambaConfig = system.readFromFile(SAMBA_CONFIG)
  sambaConfig += "\n\n%s" % shareConfig
  
  sambaConfig = setShareDetails(share, description, public=public, sambaConfig=sambaConfig)
   
  system.writeToConfigFile("/etc/samba/smb.conf",sambaConfig)
 
  restart()
Пример #2
0
def addShare(share, group=None, description=None, public=False):
    debugOutput("Adding Samba share '%s'" % (share))

    if not group: group = groupNameFromShare(share)

    sharePath = os.path.join(SAMBA_SHARES_PATH, share)

    if share in getShares():
        if not smartbox.options.testRun:
            interface.abort(
                "The share '%s' exists or has been defined already" %
                sharePath)

    if group not in system.readFromFile("/etc/group"):
        system.addGroup(group)

    if not os.path.exists(sharePath):
        system.run("""mkdir -p "%s" """ % sharePath, exitOnFail=False)
    system.run("""chgrp %s "%s" """ % (group, sharePath))
    system.run("""chmod 6770 "%s" """ % sharePath)

    shareConfig = _createShareConfig(share, sharePath, group, description)

    sambaConfig = system.readFromFile(SAMBA_CONFIG)
    sambaConfig += "\n\n%s" % shareConfig

    sambaConfig = setShareDetails(share,
                                  description,
                                  public=public,
                                  sambaConfig=sambaConfig)

    system.writeToConfigFile("/etc/samba/smb.conf", sambaConfig)

    restart()
Пример #3
0
def install(domain):

    if isInstalled():
        return

    debugOutput("Installing samba")

    apt.install("samba samba-common libcupsys2 libkrb53 winbind smbclient")

    interface.updateProgress()

    sambaConfig = _createConfig(domain)
    debugOutput(sambaConfig)
    # XXX: Warning, what if samba file exists.
    system.writeToConfigFile(SAMBA_CONFIG, sambaConfig)

    system.run("""mkdir -p "%s" """ % SAMBA_HOME)
    system.run("""mkdir -p "%s/netlogon" """ % SAMBA_HOME)
    system.run("""mkdir -p "%s/profiles" """ % SAMBA_HOME)
    system.run("""mkdir -p "%s/data" """ % SAMBA_HOME)
    system.run("""mkdir -p "%s" """ % SAMBA_USERS_PATH)
    system.run("""mkdir -p "%s" """ % SAMBA_SHARES_PATH)
    system.run("""mkdir -p /var/spool/samba""", exitOnFail=False)
    system.run("""chmod 777 /var/spool/samba/""")
    system.run("""chmod 770 "%s/profiles" """ % SAMBA_HOME)
    system.run("""chmod 770 "%s/netlogon" """ % SAMBA_HOME)
    system.run("""chmod 775 "%s" """ % SAMBA_USERS_PATH)
    system.run("""chown -R root:users "%s/" || chmod -R 771 "%s/" """ %
               (SAMBA_HOME, SAMBA_HOME))

    interface.updateProgress()

    restart()

    interface.updateProgress()

    nsswitchString = system.readFromFile("/etc/nsswitch.conf")
    onsswitchString = nsswitchString
    nsswitchString = nsswitchString.replace("files dns", "files wins dns")
    if nsswitchString != onsswitchString:
        system.writeToConfigFile("/etc/nsswitch.conf", nsswitchString)

    system.run("net groupmap add ntgroup='Domain Admins' unixgroup=root")
    system.run("net groupmap add ntgroup='Domain Users' unixgroup=users")
    system.run("net groupmap add ntgroup='Domain Guests' unixgroup=nogroup")

    # TODO: Check this has not been done.
    system.run("echo 'root = Administrator' > /etc/samba/smbusers")

    interface.updateProgress()

    # Add a default share that all users can access.
    if not "Files" in getShares():
        addShare("Files")
Пример #4
0
def configure():
    # Enable mysql extensions.
    phpConfigFile = "/etc/php4/apache2/php.ini"
    phpConfig = system.readFromFile(phpConfigFile)

    phpConfig = phpConfig.replace(";extension=mysql.so", "extension=mysql.so")

    system.writeToConfigFile(phpConfigFile, phpConfig)

    # TODO: Boost php memory.

    sbapache.restart()
Пример #5
0
def configure() :
  # Enable mysql extensions.
  phpConfigFile = "/etc/php4/apache2/php.ini"
  phpConfig = system.readFromFile(phpConfigFile)

  phpConfig = phpConfig.replace(";extension=mysql.so","extension=mysql.so")

  system.writeToConfigFile(phpConfigFile, phpConfig)

  # TODO: Boost php memory.

  sbapache.restart()
Пример #6
0
def install(domain) :
  
  if isInstalled() :
    return
  
  debugOutput("Installing samba")
  
  apt.install("samba samba-common libcupsys2 libkrb53 winbind smbclient")
 
  interface.updateProgress();
 
  sambaConfig = _createConfig(domain)
  debugOutput(sambaConfig)
  # XXX: Warning, what if samba file exists.
  system.writeToConfigFile(SAMBA_CONFIG, sambaConfig)
  
  system.run("""mkdir -p "%s" """ % SAMBA_HOME)
  system.run("""mkdir -p "%s/netlogon" """ % SAMBA_HOME)
  system.run("""mkdir -p "%s/profiles" """ % SAMBA_HOME)
  system.run("""mkdir -p "%s/data" """ % SAMBA_HOME)
  system.run("""mkdir -p "%s" """ % SAMBA_USERS_PATH)
  system.run("""mkdir -p "%s" """ % SAMBA_SHARES_PATH)
  system.run("""mkdir -p /var/spool/samba""", exitOnFail=False)
  system.run("""chmod 777 /var/spool/samba/""")
  system.run("""chmod 770 "%s/profiles" """ % SAMBA_HOME)
  system.run("""chmod 770 "%s/netlogon" """ % SAMBA_HOME)
  system.run("""chmod 775 "%s" """ % SAMBA_USERS_PATH)
  system.run("""chown -R root:users "%s/" || chmod -R 771 "%s/" """ % (SAMBA_HOME, SAMBA_HOME))

  interface.updateProgress();
  
  restart()

  interface.updateProgress();
  
  nsswitchString = system.readFromFile("/etc/nsswitch.conf")
  onsswitchString = nsswitchString
  nsswitchString = nsswitchString.replace("files dns","files wins dns")
  if nsswitchString != onsswitchString :
    system.writeToConfigFile("/etc/nsswitch.conf", nsswitchString)

  system.run("net groupmap add ntgroup='Domain Admins' unixgroup=root")
  system.run("net groupmap add ntgroup='Domain Users' unixgroup=users")
  system.run("net groupmap add ntgroup='Domain Guests' unixgroup=nogroup")

  # TODO: Check this has not been done.
  system.run("echo 'root = Administrator' > /etc/samba/smbusers")
  
  interface.updateProgress();
  
  # Add a default share that all users can access.
  if not "Files" in getShares() :
    addShare("Files")
Пример #7
0
def prepareSystem():
  
  debugOutput("Configuring the Apt package manager")
  aptSources = system.readFromFile(APT_SOURCES).lower()
  originalSources = aptSources

  aptSources = re.compile("^\s*deb cdrom", re.MULTILINE).sub("#deb cdrom", aptSources)
  aptSources = re.compile("^#\s*deb http", re.MULTILINE).sub("deb http", aptSources)
  aptSources = re.compile("^#\s*deb-src http", re.MULTILINE).sub("deb-src http", aptSources)
  
  if aptSources != originalSources :
    debugOutput("Updating sources.")
    print "Preparing the system"
    system.writeToConfigFile(APT_SOURCES, aptSources)
    update()
  else :
    debugOutput("Package sources do not need updating.")
Пример #8
0
def prepareSystem():

    debugOutput("Configuring the Apt package manager")
    aptSources = system.readFromFile(APT_SOURCES).lower()
    originalSources = aptSources

    aptSources = re.compile("^\s*deb cdrom",
                            re.MULTILINE).sub("#deb cdrom", aptSources)
    aptSources = re.compile("^#\s*deb http",
                            re.MULTILINE).sub("deb http", aptSources)
    aptSources = re.compile("^#\s*deb-src http",
                            re.MULTILINE).sub("deb-src http", aptSources)

    if aptSources != originalSources:
        debugOutput("Updating sources.")
        print "Preparing the system"
        system.writeToConfigFile(APT_SOURCES, aptSources)
        update()
    else:
        debugOutput("Package sources do not need updating.")
Пример #9
0
def install(backupSources=None) :
  debugOutput("Installing rsnapshot")
  apt.install("rsnapshot")


  # TODO: Sort out config file handling.
  system.run("mkdir /.rsnapshot", exitOnFail=False)
  system.run("chmod +rx /.rsnapshot")

  rsnapshotConf = system.readFromFile("/etc/rsnapshot.conf")
  rsnapshotConf = rsnapshotConf.replace("snapshot_root\t/var/cache/rsnapshot/","snapshot_root\t/.rsnapshot/")
  #rsnapshotConf = rsnapshotConf.replace("#no_create_root\t1","no_create_root\t0")
  rsnapshotConf = rsnapshotConf.replace("#interval","interval")
  rsnapshotConf = rsnapshotConf.replace("\nbackup","\n#backup")

  rsnapshotConf += "\n\n"

  for backupSource in backupSources :
    rsnapshotConf += "backup\t%s/\tbackups/\n" % backupSource.rstrip("/")
  rsnapshotConf += "backup\t/home/\t.system/\n"
  rsnapshotConf += "backup\t/etc/\t.system/\n"

  debugOutput(rsnapshotConf)

  system.writeToConfigFile("/etc/rsnapshot.conf",rsnapshotConf)
  
  cronConf = system.readFromFile("/etc/cron.d/rsnapshot")
  cronConf = cronConf.replace("# 0","0")
  cronConf = cronConf.replace("# 30","30")
  cronConf = cronConf.replace("*/4","*")
  
  debugOutput(cronConf)
  
  system.writeToConfigFile("/etc/cron.d/rsnapshot", cronConf)
  
  interface.updateProgress()

  system.run("rsnapshot hourly")

  interface.updateProgress()
Пример #10
0
def install(backupSources=None):
    debugOutput("Installing rsnapshot")
    apt.install("rsnapshot")

    # TODO: Sort out config file handling.
    system.run("mkdir /.rsnapshot", exitOnFail=False)
    system.run("chmod +rx /.rsnapshot")

    rsnapshotConf = system.readFromFile("/etc/rsnapshot.conf")
    rsnapshotConf = rsnapshotConf.replace(
        "snapshot_root\t/var/cache/rsnapshot/", "snapshot_root\t/.rsnapshot/")
    #rsnapshotConf = rsnapshotConf.replace("#no_create_root\t1","no_create_root\t0")
    rsnapshotConf = rsnapshotConf.replace("#interval", "interval")
    rsnapshotConf = rsnapshotConf.replace("\nbackup", "\n#backup")

    rsnapshotConf += "\n\n"

    for backupSource in backupSources:
        rsnapshotConf += "backup\t%s/\tbackups/\n" % backupSource.rstrip("/")
    rsnapshotConf += "backup\t/home/\t.system/\n"
    rsnapshotConf += "backup\t/etc/\t.system/\n"

    debugOutput(rsnapshotConf)

    system.writeToConfigFile("/etc/rsnapshot.conf", rsnapshotConf)

    cronConf = system.readFromFile("/etc/cron.d/rsnapshot")
    cronConf = cronConf.replace("# 0", "0")
    cronConf = cronConf.replace("# 30", "30")
    cronConf = cronConf.replace("*/4", "*")

    debugOutput(cronConf)

    system.writeToConfigFile("/etc/cron.d/rsnapshot", cronConf)

    interface.updateProgress()

    system.run("rsnapshot hourly")

    interface.updateProgress()