Exemple #1
0
def brSetup():
    if request.method == 'GET':
        return render_mako('brSetup.html')

    elif request.method == 'POST':

        br = lowpan.getBRInfo(request.form['eui'], request.form['brkey'])
        
        lowpan.createDefaultConf()
        lowpanConf = json.loads(db.get('conf/lowpan'))
        lowpanConf['eui'] = request.form['eui']
        lowpanConf['password'] = request.form['brkey']
        lowpanConf['url'] = BASE_URL + request.form['eui']

        db.store('conf/lowpan', json.dumps(lowpanConf))
        db.store('conf/br', json.dumps(br))

        # change root password
        os.system('echo "root:%s" | chpasswd' % (br['pin']))
        # also set login password to pin
        conf['password'] = bcrypt.generate_password_hash(br['pin'])
        db.store('conf/bradmin', json.dumps(conf, sort_keys=True, indent=4))
        # set the hostname
        os.system('hostnamectl set-hostname br12-%s' % (lowpanConf['eui']))

        os.system('sleep 3 && systemctl restart bramble')

        return "Now you need to restart BRamble"
Exemple #2
0
def brSetup():
    if request.method == 'GET':
        return render_mako('brSetup.html', url=BASE_URL)

    elif request.method == 'POST':

        baseurl = BASE_URL
        br = {}
        if request.form['url'] != '':
            baseurl = request.form['url']
            if baseurl[-1] != '/':
                baseurl = baseurl + '/'
            br = lowpan.getBRInfo(request.form['eui'], request.form['brkey'],
                                  baseurl)
        else:
            br = lowpan.getBRInfo(request.form['eui'], request.form['brkey'])

        lowpan.createDefaultConf()
        lowpanConf = json.loads(db.get('conf/lowpan'))
        lowpanConf['eui'] = request.form['eui']
        lowpanConf['password'] = request.form['brkey']
        lowpanConf['url'] = baseurl + request.form['eui']

        db.store('conf/lowpan', json.dumps(lowpanConf))
        db.store('conf/lowpan.factory', json.dumps(lowpanConf))
        db.store('conf/br', json.dumps(br))
        db.store('conf/br.factory', json.dumps(br))

        lowpan.syncConfig()
        lowpan.updateGogoc()

        # set the radio's serial (which also sets the eui)
        try:
            radio.setSerial(br['m12serial'])
        except KeyError:
            print "Warning: no m12 serial number set"
    # change root password
        os.system('echo "root:%s" | chpasswd' % (br['pin']))
        # also set login password to pin
        conf['password'] = bcrypt.generate_password_hash(br['pin'])
        db.store('conf/bradmin', json.dumps(conf, sort_keys=True, indent=4))
        db.store('conf/bradmin.factory',
                 json.dumps(conf, sort_keys=True, indent=4))
        # set the hostname
        os.system('hostnamectl set-hostname br12-%s' % (lowpanConf['eui']))

        return "Now you need to restart BRamble"
Exemple #3
0
def brSetup():
    if request.method == 'GET':
        return render_mako('brSetup.html', url=BASE_URL)

    elif request.method == 'POST':

	baseurl = BASE_URL
        br = {}
	if request.form['url'] != '':
	    baseurl = request.form['url']
	    if baseurl[-1] != '/':
	        baseurl = baseurl + '/'
            br = lowpan.getBRInfo(request.form['eui'], request.form['brkey'], baseurl)
        else: 
            br = lowpan.getBRInfo(request.form['eui'], request.form['brkey'])

        lowpan.createDefaultConf()
        lowpanConf = json.loads(db.get('conf/lowpan'))
        lowpanConf['eui'] = request.form['eui']
        lowpanConf['password'] = request.form['brkey']
        lowpanConf['url'] = baseurl + request.form['eui']

        db.store('conf/lowpan', json.dumps(lowpanConf))
        db.store('conf/lowpan.factory', json.dumps(lowpanConf))
        db.store('conf/br', json.dumps(br))
        db.store('conf/br.factory', json.dumps(br))

        lowpan.syncConfig()
        lowpan.updateGogoc()

        # set the radio's serial (which also sets the eui)
        try:
            radio.setSerial(br['m12serial'])
        except KeyError:
            print "Warning: no m12 serial number set"
        # change root password
        os.system('echo "root:%s" | chpasswd' % (br['pin']))
        # also set login password to pin
        conf['password'] = bcrypt.generate_password_hash(br['pin'])
        db.store('conf/bradmin', json.dumps(conf, sort_keys=True, indent=4))
        db.store('conf/bradmin.factory', json.dumps(conf, sort_keys=True, indent=4))
        # set the hostname
        os.system('hostnamectl set-hostname br12-%s' % (lowpanConf['eui']))

        return "Now you need to restart BRamble"