Exemple #1
0
 def get_temp(self):
     if detect_architecture()[1] == 'Raspberry Pi':
         return '%3.1f°C'%(float(shell('cat /sys/class/thermal/thermal_zone0/temp').split('\n')[0])/1000)
     else:
         if os.path.exists('/sys/class/hwmon/hwmon1/temp1_input'):
             return '%3.1f°C'%(float(shell('cat /sys/class/hwmon/hwmon1/temp1_input'))/1000)
     return ''
Exemple #2
0
 def get_temp(self):
     if detect_architecture()[1] == 'Raspberry Pi':
         return '%3.1f°C' % (float(
             shell('cat /sys/class/thermal/thermal_zone0/temp').split('\n')
             [0]) / 1000)
     else:
         if os.path.exists('/sys/class/hwmon/hwmon1/temp1_input'):
             return '%3.1f°C' % (float(
                 shell('cat /sys/class/hwmon/hwmon1/temp1_input')) / 1000)
     return ''
Exemple #3
0
 def __init__(self):
     ConfigParser.__init__(self)
     self.set('platform', detect_platform())  # TODO: move this out
     arch, board = detect_architecture()
     self.set('arch', arch)
     self.set('board', board)
Exemple #4
0
 def __init__(self):
     ConfigParser.__init__(self)
     self.set('platform', detect_platform()) # TODO: move this out
     arch, board = detect_architecture()
     self.set('arch', arch)
     self.set('board', board)
Exemple #5
0
    def post_install(self, name, path, vars):
        phpctl = apis.langassist(self.app).get_interface('PHP')
        datadir = ''
        dbase = apis.databases(self.app).get_interface('MariaDB')
        conn = apis.databases(self.app).get_dbconn('MariaDB')
        if vars.getvalue('oc-dbname', '') == '':
            dbname = name
        else:
            dbname = vars.getvalue('oc-dbname')
        secret_key = hashlib.sha1(str(random.random())).hexdigest()
        if vars.getvalue('oc-dbpasswd', '') == '':
            passwd = secret_key[0:8]
        else:
            passwd = vars.getvalue('oc-dbpasswd')
        username = vars.getvalue('oc-username')
        logpasswd = vars.getvalue('oc-logpasswd')

        # Request a database and user to interact with it
        dbase.add(dbname, conn)
        dbase.usermod(dbname, 'add', passwd, conn)
        dbase.chperm(dbname, dbname, 'grant', conn)

        # Set ownership as necessary
        if not os.path.exists(os.path.join(path, 'data')):
            os.makedirs(os.path.join(path, 'data'))
        shell('chown -R http:http '+os.path.join(path, 'apps'))
        shell('chown -R http:http '+os.path.join(path, 'data'))
        shell('chown -R http:http '+os.path.join(path, 'config'))

        # If there is a custom path for the data directory, do the magic
        if vars.getvalue('oc-ddir', '') != '':
            datadir = vars.getvalue('oc-ddir')
            if not os.path.exists(os.path.join(datadir if datadir else path, 'data')):
                os.makedirs(os.path.join(datadir if datadir else path, 'data'))
            shell('chown -R http:http '+os.path.join(datadir if datadir else path, 'data'))
            phpctl.open_basedir('add', datadir)

        # Create ownCloud automatic configuration file
        f = open(os.path.join(path, 'config', 'autoconfig.php'), 'w')
        f.write(
            '<?php\n'
            '   $AUTOCONFIG = array(\n'
            '   "adminlogin" => "'+username+'",\n'
            '   "adminpass" => "'+logpasswd+'",\n'
            '   "dbtype" => "mysql",\n'
            '   "dbname" => "'+dbname+'",\n'
            '   "dbuser" => "'+dbname+'",\n'
            '   "dbpass" => "'+passwd+'",\n'
            '   "dbhost" => "localhost",\n'
            '   "dbtableprefix" => "",\n'
            '   "directory" => "'+os.path.join(datadir if datadir else path, 'data')+'",\n'
            '   );\n'
            '?>\n'
            )
        f.close()
        shell('chown http:http '+os.path.join(path, 'config', 'autoconfig.php'))

        # Make sure that the correct PHP settings are enabled
        phpctl.enable_mod('mysql', 'pdo_mysql', 'zip', 'gd',
            'iconv', 'openssl', 'xcache')
        
        # Make sure xcache has the correct settings, otherwise ownCloud breaks
        f = open('/etc/php/conf.d/xcache.ini', 'w')
        oc = ['extension=xcache.so\n',
            'xcache.size=64M\n',
            'xcache.var_size=64M\n',
            'xcache.admin.enable_auth = Off\n',
            'xcache.admin.user = "******"\n',
            'xcache.admin.pass = "******"\n']
        f.writelines(oc)
        f.close()

        # Return an explicatory message
        if detect_architecture()[1] == 'Raspberry Pi':
            return ('ownCloud takes a long time to set up on the RPi. '
            'Once you open the page for the first time, it may take 5-10 '
            'minutes for the content to appear. Please do not refresh the '
            'page.')
Exemple #6
0
    def post_install(self, name, path, vars):
        phpctl = apis.langassist(self.app).get_interface('PHP')
        datadir = ''
        dbase = apis.databases(self.app).get_interface('MariaDB')
        conn = apis.databases(self.app).get_dbconn('MariaDB')
        if vars.getvalue('oc-dbname', '') == '':
            dbname = name
        else:
            dbname = vars.getvalue('oc-dbname')
        secret_key = hashlib.sha1(str(random.random())).hexdigest()
        if vars.getvalue('oc-dbpasswd', '') == '':
            passwd = secret_key[0:8]
        else:
            passwd = vars.getvalue('oc-dbpasswd')
        username = vars.getvalue('oc-username')
        logpasswd = vars.getvalue('oc-logpasswd')

        # Request a database and user to interact with it
        dbase.add(dbname, conn)
        dbase.usermod(dbname, 'add', passwd, conn)
        dbase.chperm(dbname, dbname, 'grant', conn)

        # Set ownership as necessary
        if not os.path.exists(os.path.join(path, 'data')):
            os.makedirs(os.path.join(path, 'data'))
        shell('chown -R http:http ' + os.path.join(path, 'apps'))
        shell('chown -R http:http ' + os.path.join(path, 'data'))
        shell('chown -R http:http ' + os.path.join(path, 'config'))

        # If there is a custom path for the data directory, do the magic
        if vars.getvalue('oc-ddir', '') != '':
            datadir = vars.getvalue('oc-ddir')
            if not os.path.exists(
                    os.path.join(datadir if datadir else path, 'data')):
                os.makedirs(os.path.join(datadir if datadir else path, 'data'))
            shell('chown -R http:http ' +
                  os.path.join(datadir if datadir else path, 'data'))
            phpctl.open_basedir('add', datadir)

        # Create ownCloud automatic configuration file
        f = open(os.path.join(path, 'config', 'autoconfig.php'), 'w')
        f.write('<?php\n'
                '   $AUTOCONFIG = array(\n'
                '   "adminlogin" => "' + username + '",\n'
                '   "adminpass" => "' + logpasswd + '",\n'
                '   "dbtype" => "mysql",\n'
                '   "dbname" => "' + dbname + '",\n'
                '   "dbuser" => "' + dbname + '",\n'
                '   "dbpass" => "' + passwd + '",\n'
                '   "dbhost" => "localhost",\n'
                '   "dbtableprefix" => "",\n'
                '   "directory" => "' +
                os.path.join(datadir if datadir else path, 'data') + '",\n'
                '   );\n'
                '?>\n')
        f.close()
        shell('chown http:http ' +
              os.path.join(path, 'config', 'autoconfig.php'))

        # Make sure that the correct PHP settings are enabled
        phpctl.enable_mod('mysql', 'pdo_mysql', 'zip', 'gd', 'iconv',
                          'openssl', 'xcache')

        # Make sure xcache has the correct settings, otherwise ownCloud breaks
        f = open('/etc/php/conf.d/xcache.ini', 'w')
        oc = [
            'extension=xcache.so\n', 'xcache.size=64M\n',
            'xcache.var_size=64M\n', 'xcache.admin.enable_auth = Off\n',
            'xcache.admin.user = "******"\n',
            'xcache.admin.pass = "******"\n'
        ]
        f.writelines(oc)
        f.close()

        # Return an explicatory message
        if detect_architecture()[1] == 'Raspberry Pi':
            return (
                'ownCloud takes a long time to set up on the RPi. '
                'Once you open the page for the first time, it may take 5-10 '
                'minutes for the content to appear. Please do not refresh the '
                'page.')