diaspora: Templates to setup domain name

This commit is contained in:
Joseph Nuthalpati authored and James Valleroy committed 2017-05-06 07:25:42 -04:00
1 parent 747a02adf2
commit 5ffcf42278
8 files changed
+284 -86

No files matched your search

+52 -15
View File
@@ -16,7 +16,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Configuration helper for diaspora* pod.
"""
@@ -36,27 +35,68 @@ def parse_arguments():
'pre-install',
help='Preseed debconf values before packages are installed.')
subparsers.add_parser('enable', help='Enable diaspora*')
subparsers.add_parser('disable', help='Disable diaspora*')
subparsers.add_parser('disable-ssl', help="Disable SSL on the diaspora* application server")
subparsers.add_parser('enable', help='Enable diaspora* web server')
subparsers.add_parser('disable', help='Disable diaspora* web server')
subparsers.add_parser('start-diaspora', help='Start diaspora* service')
subparsers.add_parser(
'disable-ssl', help="Disable SSL on the diaspora* application server")
setup = subparsers.add_parser(
'setup', help='Set Domain name for diaspora*')
setup.add_argument(
'--domain-name', help='The domain name that will be used by diaspora*')
return parser.parse_args()
def subcommand_setup(arguments):
"""Set the domain_name in diaspora configuration files"""
domain_name = arguments.domain_name
with open('/etc/diaspora/domain_name', 'w') as dnf:
dnf.write(domain_name)
set_domain_name(domain_name)
action_utils.service_start('diaspora')
action_utils.webserver_enable('diaspora-plinth')
def set_domain_name(domain_name):
"""Write a new domain name to diaspora configuration files"""
# This did not set the domain_name
# action_utils.dpkg_reconfigure('diaspora-common',
# {'url': domain_name})
# Manually changing the domain name in the conf files.
conf_file = '/etc/diaspora.conf'
with open(conf_file, 'r') as conf:
env_vars = conf.read().splitlines()
for index, line in enumerate(env_vars):
if "SERVER_NAME" in line:
env_vars[index] = "export SERVER_NAME={}".format(domain_name)
if "ENVIRONMENT_URL" in line:
env_vars[index] = "export ENVIRONMENT_URL=http://{}:3000".format(
domain_name)
with open(conf_file, 'w') as conf:
conf.write("\n".join(env_vars))
action_utils.service_start('diaspora')
def subcommand_disable_ssl(_):
"""
Disable ssl in the diaspora configuration
as the apache server takes care of ssl
"""
subprocess.call(["sed", "-i",
"s/#require_ssl: true/require_ssl: false/g",
"/etc/diaspora/diaspora.yml"])
subprocess.call([
"sed", "-i", "s/#require_ssl: true/require_ssl: false/g",
"/etc/diaspora/diaspora.yml"
])
def subcommand_pre_install(arguments):
def subcommand_pre_install(_):
"""Pre installation configuration for diaspora"""
presets= [
b'diaspora-common diaspora-common/url string http://localhost/diaspora',
presets = [
b'diaspora-common diaspora-common/url string dummy_domain_name',
b'diaspora-common diaspora-common/dbpass note ',
b'diaspora-common diaspora-common/enablessl boolean false',
b'diaspora-common diaspora-common/useletsencrypt string false',
@@ -72,19 +112,17 @@ def subcommand_pre_install(arguments):
for preset in presets:
subprocess.check_output(['debconf-set-selections'], input=preset)
# hostname = arguments.hostname or socket.gethostname()
# subprocess.check_output(
# ['debconf-set-selections'],
# input=b'diaspora diaspora/url string ' + hostname.encode())
def subcommand_enable(_):
"""Enable web configuration and reload."""
action_utils.service_enable('diaspora')
action_utils.webserver_enable('diaspora-plinth')
def subcommand_disable(_):
"""Disable web configuration and reload."""
action_utils.webserver_disable('diaspora-plinth')
action_utils.service_disable('diaspora')
def main():
@@ -98,4 +136,3 @@ def main():
if __name__ == '__main__':
main()