Skip to content

Instantly share code, notes, and snippets.

@clburlison
Last active February 28, 2018 19:36
Show Gist options
  • Select an option

  • Save clburlison/83a0753810e110cbef967a4cc3f0ef74 to your computer and use it in GitHub Desktop.

Select an option

Save clburlison/83a0753810e110cbef967a4cc3f0ef74 to your computer and use it in GitHub Desktop.

Revisions

  1. Clayton Burlison revised this gist Feb 2, 2017. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion mwa2_ubuntu16.md
    Original file line number Diff line number Diff line change
    @@ -106,4 +106,5 @@ Disable nginx
    `sudo systemctl stop nginx`

    Run the mwa2 service directly with NOTE this is on port 80
    `/usr/local/mwa2_env/bin/python /usr/local/mwa2_env/mwa2/manage.py runwsgiserver port=80 host=0.0.0.0`

    /usr/local/mwa2_env/bin/python /usr/local/mwa2_env/mwa2/manage.py runwsgiserver port=80 host=0.0.0.0
  2. Clayton Burlison revised this gist Feb 2, 2017. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion mwa2_ubuntu16.md
    Original file line number Diff line number Diff line change
    @@ -39,7 +39,8 @@ other configurations you might have.
    A script to install mwa2. So read the commands if you want to know what is happening.
    First lets write the script to disk. This script does the installation.

    `mkdir /setup`
    `mkdir /setup`

    `nano /setup/mwa2_install.sh`

    Make sure and change the very last echo line to match the info you want.
    @@ -91,6 +92,7 @@ Let's create a service to run mwa2

    Start and enable the serivce
    `systemctl start mwa2`

    `systemctl enable mwa2`

    Restart our web server
  3. Clayton Burlison revised this gist Feb 2, 2017. 1 changed file with 21 additions and 19 deletions.
    40 changes: 21 additions & 19 deletions mwa2_ubuntu16.md
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,18 @@
    # A dirty guide to setup [MWA2](https://github.com/munki/mwa2) on Ubuntu 16.
    # I want to convert this into a blog just haven't found the time.
    A dirty guide to setup [MWA2](https://github.com/munki/mwa2) on Ubuntu 16.
    I want to convert this into a blog just haven't found the time.

    # Go full yolo
    Go full yolo
    `sudo su`

    # Install packages
    Install packages
    `apt-get install git nginx python-pip python-dev`

    # Let's create our mwa2 web config (no ssl so it's easier & using root because yolo)
    # This is also bad practice since we're writing directly to sites-available
    Let's create our mwa2 web config (no ssl so it's easier & using root because yolo)
    This is also bad practice since we're writing directly to sites-enabled.
    You might need to make changes to this config so it doesn't fight with
    other configurations you might have.

    `nano /etc/nginx/sites-available/mwa2.conf`
    `nano /etc/nginx/sites-enabled/mwa2.conf`

    server {
    listen 80; # Might need an alternative port like 8080 if no DNS access
    @@ -34,14 +36,14 @@
    }


    # A script to install mwa2. So read the commands if you want to know what is happening.
    # First lets write the script to disk. This script does the installation.
    A script to install mwa2. So read the commands if you want to know what is happening.
    First lets write the script to disk. This script does the installation.

    `mkdir /setup`
    `nano /setup/mwa2_install.sh`

    # Make sure and change the very last echo line to match the info you want.
    # Default account is U: admin P: password
    Make sure and change the very last echo line to match the info you want.
    Default account is U: admin P: password

    #!/bin/bash
    set -x
    @@ -67,13 +69,13 @@
    deactivate
    chown -R mwa2_user:mwa2_user /usr/local/mwa2_env

    # Add execute bit
    Add execute bit
    `chmod +x /setup/mwa2_install.sh`

    # Run the script
    Run the script
    `/setup/mwa2_install.sh`

    # Let's create a service to run mwa2
    Let's create a service to run mwa2
    `nano /etc/systemd/system/mwa2.service`

    [Unit]
    @@ -87,19 +89,19 @@
    [Install]
    WantedBy=multi-user.target

    # Start and enable the serivce
    Start and enable the serivce
    `systemctl start mwa2`
    `systemctl enable mwa2`

    # Restart our web server
    Restart our web server
    `systemctl restart nginx`


    ---

    # Troubleshooting
    # Disable nginx
    Disable nginx
    `sudo systemctl stop nginx`

    # Run the mwa2 service directly with NOTE this is on port 80
    /usr/local/mwa2_env/bin/python /usr/local/mwa2_env/mwa2/manage.py runwsgiserver port=80 host=0.0.0.0
    Run the mwa2 service directly with NOTE this is on port 80
    `/usr/local/mwa2_env/bin/python /usr/local/mwa2_env/mwa2/manage.py runwsgiserver port=80 host=0.0.0.0`
  4. Clayton Burlison created this gist Feb 2, 2017.
    105 changes: 105 additions & 0 deletions mwa2_ubuntu16.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,105 @@
    # A dirty guide to setup [MWA2](https://github.com/munki/mwa2) on Ubuntu 16.
    # I want to convert this into a blog just haven't found the time.

    # Go full yolo
    `sudo su`

    # Install packages
    `apt-get install git nginx python-pip python-dev`

    # Let's create our mwa2 web config (no ssl so it's easier & using root because yolo)
    # This is also bad practice since we're writing directly to sites-available

    `nano /etc/nginx/sites-available/mwa2.conf`

    server {
    listen 80; # Might need an alternative port like 8080 if no DNS access
    server_name admin.example.com; # Change this

    location = /favicon.ico { access_log off; log_not_found off; }

    location / {
    proxy_pass http://127.0.0.1:8001;
    proxy_set_header X-Forwarded-Host $server_name;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
    port_in_redirect off;
    proxy_connect_timeout 300s;
    proxy_send_timeout 600s;
    proxy_read_timeout 600s;
    }
    }


    # A script to install mwa2. So read the commands if you want to know what is happening.
    # First lets write the script to disk. This script does the installation.

    `mkdir /setup`
    `nano /setup/mwa2_install.sh`

    # Make sure and change the very last echo line to match the info you want.
    # Default account is U: admin P: password

    #!/bin/bash
    set -x
    useradd -M mwa2_user
    usermod -L mwa2_user
    pip install virtualenv
    cd /usr/local/
    virtualenv mwa2_env
    cd mwa2_env
    source bin/activate
    pip install Django==1.9.1
    pip install django-wsgiserver==0.8.0rc1
    pip install gunicorn==19.4.5
    sed -i "s/self.validate(display_num_errors=True)/self.check(display_num_errors=True)/" lib/python2.7/site-packages/django_wsgiserver/management/commands/runwsgiserver.py
    git clone https://github.com/munki/mwa2.git
    git clone https://github.com/munki/munki.git
    cp mwa2/munkiwebadmin/settings_template.py mwa2/munkiwebadmin/settings.py
    sed -i "s/'\/Users\/Shared\/munki_repo'/'\/usr\/local\/munki_repo'/" mwa2/munkiwebadmin/settings.py
    sed -i "s/'\/usr\/local\/munki\/makecatalogs'/'\/usr\/local\/mwa2_env\/munki\/code\/client\/makecatalogs'/" mwa2/munkiwebadmin/settings.py
    python mwa2/manage.py migrate --noinput
    python mwa2/manage.py collectstatic --noinput
    echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', '[email protected]', 'password')" | python mwa2/manage.py shell
    deactivate
    chown -R mwa2_user:mwa2_user /usr/local/mwa2_env

    # Add execute bit
    `chmod +x /setup/mwa2_install.sh`

    # Run the script
    `/setup/mwa2_install.sh`

    # Let's create a service to run mwa2
    `nano /etc/systemd/system/mwa2.service`

    [Unit]
    Description=MunkiWebAdmin2
    After=network.target

    [Service]
    ExecStart=/usr/local/mwa2_env/bin/python /usr/local/mwa2_env/mwa2/manage.py runwsgiserver port=8001 host=127.0.0.1
    Restart=always

    [Install]
    WantedBy=multi-user.target

    # Start and enable the serivce
    `systemctl start mwa2`
    `systemctl enable mwa2`

    # Restart our web server
    `systemctl restart nginx`


    ---

    # Troubleshooting
    # Disable nginx
    `sudo systemctl stop nginx`

    # Run the mwa2 service directly with NOTE this is on port 80
    /usr/local/mwa2_env/bin/python /usr/local/mwa2_env/mwa2/manage.py runwsgiserver port=80 host=0.0.0.0