mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	[manual] Switch over to new /etc/zulip/zulip.conf config file
Run the following commands as root before deploying this branch: # /root/zulip/tools/migrate-server-config # rm /etc/zulip/machinetype /etc/zulip/server /etc/zulip/local /etc/humbug-machinetype /etc/humbug-server /etc/humbug-local (imported from commit aa7dcc50d2f4792ce33834f14761e76512fca252)
This commit is contained in:
		@@ -28,14 +28,6 @@ class zulip-internal::base {
 | 
			
		||||
    source     => 'puppet:///modules/zulip-internal/root_authorized_keys',
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  # This is just an empty file.  It's used by the app to test if it's running
 | 
			
		||||
  # in production.
 | 
			
		||||
  file { '/etc/zulip/server':
 | 
			
		||||
    ensure     => file,
 | 
			
		||||
    mode       => 644,
 | 
			
		||||
    content    => '',
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  file { '/usr/local/sbin/zulip-ec2-configure-interfaces':
 | 
			
		||||
    ensure     => file,
 | 
			
		||||
    mode       => 755,
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,2 @@
 | 
			
		||||
class zulip-internal ($machinetype) {
 | 
			
		||||
  class { "zulip-internal::$machinetype": }
 | 
			
		||||
 | 
			
		||||
  file { '/etc/zulip/machinetype':
 | 
			
		||||
    ensure  => file,
 | 
			
		||||
    mode    => 644,
 | 
			
		||||
    content => "$machinetype\n",
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Exec { path => "/usr/sbin:/usr/bin:/sbin:/bin" }
 | 
			
		||||
 | 
			
		||||
  class {'apt': }
 | 
			
		||||
 | 
			
		||||
class zulip-internal {
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -38,14 +38,6 @@ class zulip::local_server {
 | 
			
		||||
    target => '/home/zulip/deployments/current/prod-static/serve',
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  # This is just an empty file.  It's used by the app to test if it's running
 | 
			
		||||
  # on a local server.
 | 
			
		||||
  file { '/etc/zulip/local':
 | 
			
		||||
    ensure     => file,
 | 
			
		||||
    mode       => 644,
 | 
			
		||||
    content    => '',
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  file { "/usr/share/postgresql/9.1/tsearch_data/zulip_english.stop":
 | 
			
		||||
    require => Package["postgresql-9.1"],
 | 
			
		||||
    ensure => file,
 | 
			
		||||
 
 | 
			
		||||
@@ -15,11 +15,9 @@ logging.basicConfig(format="%(asctime)s restart-server: %(message)s",
 | 
			
		||||
deploy_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
 | 
			
		||||
os.chdir(deploy_path)
 | 
			
		||||
 | 
			
		||||
if os.path.exists("/etc/zulip/server"):
 | 
			
		||||
    with open("/etc/zulip/machinetype") as mtf:
 | 
			
		||||
        if pwd.getpwuid(os.getuid())[0] != "zulip":
 | 
			
		||||
            logging.error("Must be run as user 'zulip'.")
 | 
			
		||||
            sys.exit(1)
 | 
			
		||||
if pwd.getpwuid(os.getuid())[0] != "zulip":
 | 
			
		||||
    logging.error("Must be run as user 'zulip'.")
 | 
			
		||||
    sys.exit(1)
 | 
			
		||||
 | 
			
		||||
# Send a statsd event on restarting the server
 | 
			
		||||
subprocess.check_call(["python", "./manage.py", "send_stats", "incr", "events.server_restart", str(int(time.time()))])
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,9 @@ cp -a /root/zulip/puppet/zulip/files/puppet.conf /etc/puppet/
 | 
			
		||||
ssh $SSH_OPTS "$server" -t -i "$amazon_key_file" -lroot <<EOF
 | 
			
		||||
cp -a /root/zulip/puppet/zulip/files/puppet.conf /etc/puppet/
 | 
			
		||||
 | 
			
		||||
puppet apply -e 'class {"zulip": machinetype => "local_server"}'
 | 
			
		||||
mkdir /etc/zulip
 | 
			
		||||
echo -e "[machine]\npuppet_classes = zulip::local_server" > /etc/zulip/zulip.conf
 | 
			
		||||
/root/zulip/scripts/zulip-puppet-apply -f
 | 
			
		||||
cp -a /root/zulip /home/zulip/zulip
 | 
			
		||||
chown -R zulip:zulip /home/zulip/zulip
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,8 @@
 | 
			
		||||
 | 
			
		||||
import sys
 | 
			
		||||
import subprocess
 | 
			
		||||
import ConfigParser
 | 
			
		||||
import re
 | 
			
		||||
 | 
			
		||||
force = False
 | 
			
		||||
extra_args = sys.argv[1:]
 | 
			
		||||
@@ -10,10 +12,18 @@ if len(extra_args) and extra_args[0] in ('-f', '--force'):
 | 
			
		||||
    force = True
 | 
			
		||||
    eatra_args = extra_args[1:]
 | 
			
		||||
 | 
			
		||||
with open('/etc/zulip/machinetype') as f:
 | 
			
		||||
    machinetype = f.readline().strip()
 | 
			
		||||
config = ConfigParser.RawConfigParser()
 | 
			
		||||
config.read("/etc/zulip/zulip.conf")
 | 
			
		||||
 | 
			
		||||
puppet_cmd = ["puppet", "apply", "-e", "class {'zulip-internal': machinetype => '%s'}" % (machinetype,)]
 | 
			
		||||
puppet_config = """
 | 
			
		||||
Exec { path => "/usr/sbin:/usr/bin:/sbin:/bin" }
 | 
			
		||||
class { 'apt': }
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
for pclass in re.split(r'\s*,\s*', config.get('machine', 'puppet_classes')):
 | 
			
		||||
    puppet_config += "class { '%s': }\n" % (pclass,)
 | 
			
		||||
 | 
			
		||||
puppet_cmd = ["puppet", "apply", "-e", puppet_config]
 | 
			
		||||
puppet_cmd += extra_args
 | 
			
		||||
 | 
			
		||||
if force:
 | 
			
		||||
 
 | 
			
		||||
@@ -83,7 +83,9 @@ cp -a /root/zulip/puppet/zulip/files/puppet.conf /etc/puppet/
 | 
			
		||||
 | 
			
		||||
userdel admin
 | 
			
		||||
passwd -d root
 | 
			
		||||
puppet apply -e 'class {"zulip": machinetype => "$type"}'
 | 
			
		||||
mkdir /etc/zulip
 | 
			
		||||
echo -e "[machine]\npuppet_classes =" $type > /etc/zulip/zulip.conf
 | 
			
		||||
/root/zulip/scripts/zulip-puppet-apply -f
 | 
			
		||||
cp -a /root/zulip /home/zulip/zulip
 | 
			
		||||
chown -R zulip:zulip /home/zulip/zulip
 | 
			
		||||
# These server restarting bits should be moveable into puppet-land, ideally
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										25
									
								
								tools/migrate-server-config
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										25
									
								
								tools/migrate-server-config
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
#!/usr/bin/python
 | 
			
		||||
import os
 | 
			
		||||
import ConfigParser
 | 
			
		||||
import platform
 | 
			
		||||
import re
 | 
			
		||||
 | 
			
		||||
config = ConfigParser.RawConfigParser()
 | 
			
		||||
config.add_section("machine")
 | 
			
		||||
 | 
			
		||||
with open('/etc/zulip/machinetype') as f:
 | 
			
		||||
    machinetype = f.readline().strip()
 | 
			
		||||
 | 
			
		||||
config.set('machine', 'puppet_classes', "zulip-internal::%s" % (machinetype,))
 | 
			
		||||
 | 
			
		||||
if os.path.exists('/etc/zulip/server'):
 | 
			
		||||
    if platform.node() == 'staging.zulip.net':
 | 
			
		||||
        deploy_type = 'staging'
 | 
			
		||||
    elif not not re.match(r'^test', platform.node()):
 | 
			
		||||
        deploy_type = 'test'
 | 
			
		||||
    else:
 | 
			
		||||
        deploy_type = 'prod'
 | 
			
		||||
 | 
			
		||||
    config.set('machine', 'deploy_type', deploy_type)
 | 
			
		||||
 | 
			
		||||
config.write(open('/etc/zulip/zulip.conf', 'w'))
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
# Secret Django settings for the Zulip project
 | 
			
		||||
import os
 | 
			
		||||
import platform
 | 
			
		||||
import re
 | 
			
		||||
import ConfigParser
 | 
			
		||||
 | 
			
		||||
# Make this unique, and don't share it with anybody.
 | 
			
		||||
SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
 | 
			
		||||
@@ -44,14 +44,17 @@ EMAIL_HOST_USER = 'zulip@zulip.com'
 | 
			
		||||
EMAIL_HOST_PASSWORD = 'xxxxxxxxxxxxxxxx'
 | 
			
		||||
EMAIL_PORT = 587
 | 
			
		||||
 | 
			
		||||
config_file = ConfigParser.RawConfigParser()
 | 
			
		||||
config_file.read("/etc/zulip/zulip.conf")
 | 
			
		||||
 | 
			
		||||
# Whether we're running in a production environment. Note that DEPLOYED does
 | 
			
		||||
# **not** mean hosted by us; customer sites are DEPLOYED and LOCAL_SERVER
 | 
			
		||||
# and as such should not for example assume they are the main Zulip site.
 | 
			
		||||
DEPLOYED = os.path.exists('/etc/zulip/server')
 | 
			
		||||
STAGING_DEPLOYED = (platform.node() == 'staging.zulip.net')
 | 
			
		||||
TESTING_DEPLOYED = not not re.match(r'^test', platform.node())
 | 
			
		||||
DEPLOYED = config_file.has_option('machine', 'deploy_type')
 | 
			
		||||
STAGING_DEPLOYED = DEPLOYED and config_file.get('machine', 'deploy_type') == 'staging'
 | 
			
		||||
TESTING_DEPLOYED = DEPLOYED and config_file.get('machine', 'deploy_type') == 'test'
 | 
			
		||||
 | 
			
		||||
LOCAL_SERVER = os.path.exists('/etc/zulip-local')
 | 
			
		||||
LOCAL_SERVER = DEPLOYED and config_file.get('machine', 'deploy_type') == 'local'
 | 
			
		||||
 | 
			
		||||
if TESTING_DEPLOYED:
 | 
			
		||||
    EXTERNAL_HOST = platform.node()
 | 
			
		||||
 
 | 
			
		||||
@@ -5,19 +5,22 @@
 | 
			
		||||
import os
 | 
			
		||||
import platform
 | 
			
		||||
import time
 | 
			
		||||
import re
 | 
			
		||||
import sys
 | 
			
		||||
import ConfigParser
 | 
			
		||||
 | 
			
		||||
from zerver.openid import openid_failure_handler
 | 
			
		||||
 | 
			
		||||
config_file = ConfigParser.RawConfigParser()
 | 
			
		||||
config_file.read("/etc/zulip/zulip.conf")
 | 
			
		||||
 | 
			
		||||
# Whether we're running in a production environment. Note that DEPLOYED does
 | 
			
		||||
# **not** mean hosted by us; customer sites are DEPLOYED and LOCAL_SERVER
 | 
			
		||||
# and as such should not for example assume they are the main Zulip site.
 | 
			
		||||
DEPLOYED = os.path.exists('/etc/zulip/server')
 | 
			
		||||
STAGING_DEPLOYED = (platform.node() == 'staging.zulip.net')
 | 
			
		||||
TESTING_DEPLOYED = not not re.match(r'^test', platform.node())
 | 
			
		||||
DEPLOYED = config_file.has_option('machine', 'deploy_type')
 | 
			
		||||
STAGING_DEPLOYED = DEPLOYED and config_file.get('machine', 'deploy_type') == 'staging'
 | 
			
		||||
TESTING_DEPLOYED = DEPLOYED and config_file.get('machine', 'deploy_type') == 'test'
 | 
			
		||||
 | 
			
		||||
LOCAL_SERVER = os.path.exists('/etc/zulip-local')
 | 
			
		||||
LOCAL_SERVER = DEPLOYED and config_file.get('machine', 'deploy_type') == 'local'
 | 
			
		||||
 | 
			
		||||
# TODO: Clean this up
 | 
			
		||||
if TESTING_DEPLOYED:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user