Skip to content

Commit

Permalink
push
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDoobPG authored and MrDoobPG committed Aug 30, 2019
1 parent 1478909 commit eeb02e0
Show file tree
Hide file tree
Showing 11 changed files with 422 additions and 0 deletions.
169 changes: 169 additions & 0 deletions menu/roles/docker/tasks/main.old.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#!/bin/bash
#
# Title: PGBlitz (Reference Title File)
# Author(s): Admin9705 - Deiteq
# URL: https://pgblitz.com - http://github.pgblitz.com
# GNU: General Public License v3.0
################################################################################
---
- name: 'Establish Facts'
set_fact:
switch: 'on'
updatecheck: 'default'

- name: 'Docker Check'
stat:
path: '/usr/bin/docker'
register: check

- name: 'Docker Version Check - True'
shell: "docker --version | awk '{print $3}'"
register: updatecheck

- name: 'Switch - On'
set_fact:
switch: 'off'
when: updatecheck.stdout == "18.09.8,"

- name: Install required packages
apt:
name: '{{ packages }}'
vars:
packages:
- apt-transport-https
- ca-certificates
- software-properties-common
when: switch == "on"

- name: Add official gpg signing key
apt_key:
id: 0EBFCD88
url: https://download.docker.com/linux/ubuntu/gpg
when: switch == "on"

- name: 'Stop All Containers'
shell: 'docker stop $(docker ps -a -q)'
ignore_errors: yes
when:
- check.stat.exists == True
- switch == "on"

- name: Official Repo
apt_repository:
repo: 'deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} edge'
register: apt_docker_repositories
when: switch == "on"

- name: Update APT packages list
apt:
update_cache: yes
when: apt_docker_repositories.changed and switch == "on"

- name: Release docker-ce from hold
dpkg_selections:
name: docker-ce
selection: install
when: switch == "on"

- name: Install docker-ce
apt:
name: docker-ce
state: latest
update_cache: yes
when: switch == "on"

- name: Put docker-ce into hold
dpkg_selections:
name: docker-ce
selection: hold
when: switch == "on"

- name: Uninstall docker-py pip module
pip:
name: docker-py
state: absent
ignore_errors: yes
when: switch == "on"

- name: Install docker pip module
pip:
name: docker
state: latest
ignore_errors: yes
when: switch == "on"

- name: Check docker daemon.json exists
stat:
path: /etc/docker/daemon.json
register: docker_daemon

- name: Stop docker to enable overlay2
systemd:
state: stopped
name: docker
enabled: yes
when:
- docker_daemon.stat.exists == False
- switch == "on"

- name: Import daemon.json
copy:
src: daemon.json
dest: /etc/docker/daemon.json
force: yes
mode: 0775
when:
- docker_daemon.stat.exists == False
- switch == "on"

- name: Start docker (Please Wait)
systemd:
state: started
name: docker
enabled: yes
when:
- docker_daemon.stat.exists == False
- switch == "on"

- name: 'Wait for 20 seconds before commencing'
wait_for:
timeout: 20
when: switch == "on"

- name: Check override folder exists
stat:
path: /etc/systemd/system/docker.service.d
register: docker_override

- name: Create override folder
file:
path: /etc/systemd/system/docker.service.d
state: directory
mode: 0775
when:
- docker_override.stat.exists == False
- switch == "on"
tags: docker_standard

- name: Import override file
copy:
src: override.conf
dest: /etc/systemd/system/docker.service.d/override.conf
force: yes
mode: 0775
tags: docker_standard
when: switch == "on"

- name: create plexguide network
docker_network:
name: 'plexguide'
state: present
tags: docker_standard
when: switch == "on"

- name: 'Start All Containers'
shell: 'docker start $(docker ps -a -q)'
ignore_errors: yes
when:
- switch == "on"
- check.stat.exists == True
17 changes: 17 additions & 0 deletions menu/roles/docker/tasks/subtasks/housekeeping.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#########################################################################
# Title: Docker: Housekeeping Tasks #
# Author(s): desimaniac #
# URL: https://github.com/cloudbox/cloudbox #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
---
- name: Housekeeping | Remove all unused docker images
shell: docker image prune -af &> /dev/null || true
ignore_errors: yes

- name: Housekeeping | Remove all unused docker volumes
shell: docker volume prune -f &> /dev/null || true
ignore_errors: yes
58 changes: 58 additions & 0 deletions menu/roles/docker/tasks/subtasks/network.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#########################################################################
# Title: Docker: Network Tasks #
# Author(s): desimaniac, l3uddz #
# URL: https://github.com/cloudbox/cloudbox #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#########################################################################
# GNU General Public License v3.0 #
# Many thanks to the guys of CBox . Thansk for building this part #
#########################################################################
---
- name: Network | Get list of docker networks
shell: docker network ls --format '{{ '{{' }} .Name{{ '}}' }}'
register: docker_networks

- name: Network | Get plexguide docker network gateway
shell: docker network inspect plexguide -f '{{ '{{' }}range .IPAM.Config{{ '}}' }}{{ '{{' }}.Gateway{{ '}}' }}{{ '{{' }}end{{ '}}' }}'
register: docker_gateway
when: ('plexguide' in docker_networks.stdout_lines)

- name: "Network | Create new plexguide docker network block"
block:

- name: Create plexguide network
docker_network:
name: plexguide
state: present

when: ('plexguide' not in docker_networks.stdout_lines)

- name: "Network | Rebuild existing plexguide docker network block"
block:

- name: Network | Get list of containers on plexguide network
shell: docker ps -a --filter network=plexguide --format '{{ '{{' }}.Names{{ '}}' }}'
register: docker_containers

- name: Network | Disconnect containers from bridge network
shell: docker network disconnect -f bridge {{ item }}
with_items: "{{ docker_containers.stdout_lines }}"
register: r
failed_when: r.rc > 1
ignore_errors: yes

- name: Network | Rebuild plexguide network
docker_network:
name: plexguide
state: present
force: yes

- name: Network | Connect containers to plexguide network
shell: docker network connect plexguide {{ item }} --alias {{ item }}
with_items: "{{ docker_containers.stdout_lines }}"
register: q
failed_when: q.rc > 1
ignore_errors: yes

when: ('plexguide' in docker_networks.stdout_lines) and (docker_gateway.stdout == '172.18.0.254')
7 changes: 7 additions & 0 deletions menu/roles/docker/templates/daemon.json.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"storage-driver": "{{ ('zfs' in var_lib_file_system.stdout) | ternary('zfs','overlay2') }}",
"userland-proxy": false,
"log-driver": "json-file",
"init": true,
"log-opts": {"max-size": "10m", "max-file": "3"}
}
39 changes: 39 additions & 0 deletions menu/roles/python/files/pts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
#
# Title: PGBlitz (Reference Title File)
# Author(s): Admin9705
# URL: https://pgblitz.com - http://github.pgblitz.com
# GNU: General Public License v3.0
################################################################################
file="/var/plexguide/pg.number"
if [ -e "$file" ]; then
check="$(cat /var/plexguide/pg.number | head -c 1)"
if [[ "$check" == "5" || "$check" == "6" || "$check" == "7" ]]; then

tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🌎 INSTALLER BLOCK: Notice
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
We detected PG Version $check is running! Per the instructions, PG 8
must be installed on a FRESH BOX! Exiting!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
exit
fi
fi

source /opt/plexguide/menu/functions/functions.sh
source /opt/plexguide/menu/functions/start.sh
source /opt/plexguide/menu/functions/install.sh

mkdir -p /opt/plexguide/roles/log
mkdir -p /var/plexguide/logs
mkdir -p /opt/appdata/plexguide

sudocheck
missingpull

# pg deploy contains pgdeploy at end
pginstall
40 changes: 40 additions & 0 deletions menu/roles/python/files/ptsadd
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
##usercheck
if [ $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}') ]; then
usermod -aG sudo $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}')
sudo usermod -s /bin/bash $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}')
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo " ✅ PASSED ! We found the user UID " $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}')
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
else
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " ⌛ INFO ! "
echo " ⌛ INFO ! Only lowercase and dont empty parts"
echo " ⌛ INFO ! Enter a password (8+ chars)"
echo " ⌛ INFO ! "
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
read -p "Enter username : " username
read -s -p "Enter password : " password
echo ""
egrep "^$username" /etc/passwd >/dev/null
pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
useradd -m -p $pass $username
usermod -aG sudo $username
sudo usermod -s /bin/bash $username
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " ✅ PASSED ! User has been added to system!"
echo " ✅ PASSED ! Your Username : " $username
echo " ✅ PASSED ! Your Password : " $password
echo " ✅ PASSED ! "
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
fi
tee <<-EOF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
😂 What a Lame name: $(grep "1000" /etc/passwd | cut -d: -f1 | awk '{print $1}')
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF
exit 0
15 changes: 15 additions & 0 deletions menu/roles/python/files/ptsupdate
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
#
# Title: PGBlitz (Reference Title File)
# Author(s): Admin9705
# URL: https://pgblitz.com - http://github.pgblitz.com
# GNU: General Public License v3.0
################################################################################
source /opt/plexguide/menu/functions/functions.sh
source /opt/plexguide/menu/functions/start.sh

sudocheck
missingpull
owned
exitcheck

Loading

0 comments on commit eeb02e0

Please sign in to comment.