def init():
    external_address = sys.argv[2]
    internal_address = misc.local_ip_address()
    tinc_address = sys.argv[3]
    tincname = sys.argv[4]

    if not os.path.exists(tinc_path):
        os.makedirs(tinc_path)

    run_path = '/home/salvus/salvus/salvus/data/local/var/run/'
    if not os.path.exists(run_path):
        os.makedirs(run_path)

    tinc_up = os.path.join(tinc_path, 'tinc-up')

    open(tinc_up, 'w').write(
        "#!/bin/sh\nifconfig $INTERFACE %s netmask 255.192.0.0 txqueuelen 10000"
        % tinc_address)

    os.popen("chmod a+rx %s" % tinc_up)

    open(tinc_conf, 'w').write(
        "Name = %s\nKeyExpire = 2592000\nProcessPriority = high\n" % tincname)

    rsa_key_priv = os.path.join(tinc_path, 'rsa_key.priv')
    rsa_key_pub = os.path.join(tinc_path, 'hosts', tincname)

    if os.path.exists(rsa_key_priv): os.unlink(rsa_key_priv)
    if os.path.exists(rsa_key_pub): os.unlink(rsa_key_pub)

    os.popen("tincd --config %s -K" % tinc_path).read()

    host_file = os.path.join(hosts_path, tincname)
    public_key = open(rsa_key_pub).read().strip()

    # We give the internal address for Address= since only other GCE nodes will connect to these nodes, and
    # though using the external address would work, it would incur significant additional *charges* from Google.
    open(host_file, 'w').write(
        "Address = %s\nTCPonly=yes\nCompression=10\nCipher = aes-128-cbc\nSubnet = %s\n%s"
        % (internal_address, tinc_address, public_key))

    print json.dumps(
        {
            "tincname": tincname,
            "host_file": open(host_file).read()
        },
        separators=(',', ':'))
Example #2
0
def ip_address(dest):
    # get the ip address that is used to communicate with the given destination
    import misc
    return misc.local_ip_address(dest)
Example #3
0
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################

import hosts, os, socket, sys

sys.path.append("%s/salvus/salvus/" % os.environ['HOME'])

user = os.environ['USER']

import misc

for hostname in hosts.persistent_hosts + hosts.unsafe_hosts:
    ip = misc.local_ip_address(hostname)
    if ip.startswith('127'): continue
    cmd = 'ssh -t salvus@%s "cd salvus; git pull %s@%s:salvus/"' % (hostname,
                                                                    user, ip)
    print cmd
    os.system(cmd)

#print "Deal with these manually: ", hosts.unsafe_hosts
Example #4
0
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################



import hosts, os, socket, sys

sys.path.append("%s/salvus/salvus/"%os.environ['HOME'])

user = os.environ['USER']

import misc

for hostname in hosts.persistent_hosts + hosts.unsafe_hosts:
    ip = misc.local_ip_address(hostname)
    if ip.startswith('127'): continue
    cmd = 'ssh -t salvus@%s "cd salvus; git pull %s@%s:salvus/"'%(hostname, user, ip)
    print cmd
    os.system(cmd)

#print "Deal with these manually: ", hosts.unsafe_hosts
Example #5
0
def ip_address(dest):
    # get the ip address that is used to communicate with the given destination
    import misc
    return misc.local_ip_address(dest)