Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
56a79e7
reuse config_vars.yml for installed app tracking
jvonau Sep 5, 2019
ab39fe9
rename 'test_kalite_installed' add installed tracker
jvonau Sep 5, 2019
8fab1e5
kiwix rework and add iiab_installed
jvonau Sep 5, 2019
ebfc137
kolibri rework and add iiab_installed
jvonau Sep 5, 2019
d1e01e8
sugarizer rework and add iiab_installed
jvonau Sep 5, 2019
7c6274e
moodle rework and add iiab_installed
jvonau Sep 5, 2019
bae9084
elgg rework and add iiab_installed
jvonau Sep 1, 2019
5e62904
wordpress db setup and installed tracker
jvonau Sep 1, 2019
9dab734
nextcloud add iiab_installed and tweeks
jvonau Sep 1, 2019
529b170
awstats split and iiab_installed
jvonau Sep 5, 2019
9151498
use lineinfile
jvonau Sep 9, 2019
1e14cab
azuracast - iiab_installed
jvonau Sep 14, 2019
9756860
bluetooth - iiab_installed
jvonau Sep 14, 2019
4463e4e
calibre-web - iiab_installed
jvonau Sep 14, 2019
24f1b4f
calibre - iiab_installed
jvonau Sep 14, 2019
e7ea453
dokuwiki - iiab_installed
jvonau Sep 14, 2019
3de43a3
gitea - iiab_installed
jvonau Sep 14, 2019
4094edc
lokole - iiab_installed
jvonau Sep 14, 2019
cb5e640
mediawiki - iiab_installed
jvonau Sep 14, 2019
8302811
minetest - iiab_installed
jvonau Sep 14, 2019
a311a0f
mosquitto - iiab_installed
jvonau Sep 14, 2019
130e6a2
munin - iiab_installed
jvonau Sep 14, 2019
9565410
nodered - iiab_installed
jvonau Sep 15, 2019
2807fbc
needs True
jvonau Oct 7, 2019
5b183e1
mongodb - iiab_installed
jvonau Oct 14, 2019
c63f9ba
provide ICO fuctionality at cmdline
jvonau Oct 10, 2019
8c74448
iiab-configure - deal with web services only
jvonau Oct 16, 2019
02fe653
use config_vars2 in source yaml files
jvonau Oct 1, 2019
4e52e41
mongo installed on image but not recorded workaround
jvonau Oct 14, 2019
d8df590
iiab-install can use faster code if /etc/iiab/config_vars2.yml exists
jvonau Oct 15, 2019
46f48fa
remove when install
jvonau Oct 15, 2019
83546e5
runrole --reinstall to remove role installed marker
jvonau Oct 16, 2019
2265a24
create config_vars2.yml at start of stage-4
jvonau Oct 16, 2019
ce2ec3b
kiwix allow reinstall/updates with runrole --reinstall
jvonau Oct 16, 2019
ddf8e1d
stage 4 installed
jvonau Oct 16, 2019
c396f44
cmdline tweeks
jvonau Oct 16, 2019
b67a19c
network guard against faulty user edits to local_vars
jvonau Oct 16, 2019
8423d73
runrole - ensure local_vars has *_install is set to True
jvonau Oct 17, 2019
a66b650
iiab_state
jvonau Oct 24, 2019
800ae2f
iiab_state2
jvonau Oct 24, 2019
9a0e054
Merge pull request #305 from iiab/master
holta Oct 24, 2019
626473e
Merge pull request #306 from jvonau/installed
holta Oct 24, 2019
b533cb6
#2008 var names, output, comments, small bugs
holta Oct 25, 2019
5ae521d
double-double-quote vars in echo for safety etc
holta Oct 25, 2019
217fdc5
Fix var name captive_portal_installed (not captiveportal_installed)
holta Oct 25, 2019
1604d8e
Remove 2 unnec '| bool' clauses
holta Oct 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions iiab-configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

INVENTORY=ansible_hosts
PLAYBOOK=iiab-from-cmdline.yml
CWD=`pwd`
IIAB_STATE_FILE=/etc/iiab/iiab_state.yml
IIAB_ENV_FILE=/etc/iiab/iiab.env

if [ ! -f $PLAYBOOK ]; then
echo -e "\nEXITING: IIAB Playbook ""$PLAYBOOK"" not found."
echo -e "\nPlease run this in /opt/iiab/iiab (top level of the git repo)."
exit 1
fi

if [ -f $IIAB_ENV_FILE ]; then
STAGE=0
if grep -q STAGE= /etc/iiab/iiab.env ; then
source /etc/iiab/iiab.env
echo -e "\nExtracted STAGE=$STAGE (counter) from /etc/iiab/iiab.env"
if ! [ "$STAGE" -eq "$STAGE" ] 2> /dev/null; then
echo -e "\nEXITING: STAGE (counter) value == ""$STAGE"" is non-integer"
exit 1
elif [ "$STAGE" -lt 0 ] || [ "$STAGE" -gt 9 ]; then
echo -e "\nEXITING: STAGE (counter) value == ""$STAGE"" is out-of-range"
exit 1
elif [ "$STAGE" -lt 3 ]; then
echo -e "\nEXITING: STAGE (counter) value == ""$STAGE"
echo -e "\nIIAB Stage 3 not complete."
echo -e "\nPlease run: ./iiab-install"
exit 1
fi
else
echo -e "\nEXITING: STAGE (counter) not found"
echo -e "\nIIAB not installed."
echo -e "\nPlease run: ./iiab-install"
exit 1
fi
else
echo -e "\nEXITING: /etc/iiab/iiab.env not found"
echo -e "\nIIAB not installed."
echo -e "\nPlease run: ./iiab-install"
exit 1
fi

# Workaround for (web-published) images; will go away later
if grep -q sugar $IIAB_STATE_FILE; && ! grep -q mongodb $IIAB_STATE_FILE; then
echo "mongodb_installed: True" >> $IIAB_STATE_FILE
fi

export ANSIBLE_LOG_PATH="$CWD/iiab-configure.log"
ansible-playbook -i $INVENTORY $PLAYBOOK --connection=local
18 changes: 18 additions & 0 deletions iiab-from-cmdline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- hosts: all
become: yes

vars_files:
- vars/default_vars.yml
- vars/{{ ansible_local.local_facts.os_ver }}.yml
- /etc/iiab/local_vars.yml
- /etc/iiab/iiab_state.yml

roles:
- { role: 0-init, tags: ['0-init'] }
- { role: 4-server-options, tags: ['4-server-options'] }
- { role: 5-xo-services, tags: ['5-xo-services'] }
- { role: 6-generic-apps, tags: ['6-generic-apps'] }
- { role: 7-edu-apps, tags: ['7-edu-apps'] }
- { role: 8-mgmt-tools, tags: ['8-mgmt-tools'] }
- { role: 9-local-addons, tags: ['9-local-addons'] }
2 changes: 1 addition & 1 deletion iiab-from-console.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- vars/default_vars.yml
- vars/{{ ansible_local.local_facts.os_ver }}.yml
- /etc/iiab/local_vars.yml
- /etc/iiab/config_vars.yml
- /etc/iiab/iiab_state.yml

roles:
- { role: 0-init, tags: ['0-init'] }
Expand Down
81 changes: 51 additions & 30 deletions iiab-install
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
# Add cmdline options for passing to ansible
# Todo add proper shift to gobble up --debug --reinstall

PLAYBOOK="iiab-stages.yml"
INVENTORY="ansible_hosts"
PLAYBOOK=iiab-stages.yml
INVENTORY=ansible_hosts
IIAB_STATE_FILE=/etc/iiab/iiab_state.yml
ARGS=""
CWD=`pwd`
OS=`grep ^ID= /etc/*release|cut -d= -f2`
Expand All @@ -30,7 +31,7 @@ if [ ! -f /etc/iiab/local_vars.yml ]; then
echo -e "(2) MIN/MEDIUM/BIG samples are included in /opt/iiab/iiab/vars" >&2
echo -e "(3) NO TIME FOR DETAILS? RUN INTERNET-IN-A-BOX'S FRIENDLY 1-LINE INSTALLER:\n" >&2

echo -e ' http://download.iiab.io (click on "6.7" or a more recent version!)\n' >&2
echo -e ' http://download.iiab.io\n' >&2

exit 1
fi
Expand All @@ -46,17 +47,18 @@ cp ./scripts/local_facts.fact /etc/ansible/facts.d/local_facts.fact
echo "Placed /etc/ansible/facts.d/local_facts.fact into position."

if [ ! -f $PLAYBOOK ]; then
echo "EXITING: IIAB Playbook not found."
echo "Please run 'iiab-install' from /opt/iiab/iiab (top level of git repo)."
echo "EXITING: IIAB Playbook ""$PLAYBOOK"" not found."
echo "Please run './iiab-install' from /opt/iiab/iiab (top level of git repo)."
exit 1
fi

if [ "$1" != "--debug" ] && [ "$1" != "--reinstall" ] && [ "$1" != "" ]; then
echo "Use './iiab-install' for regular installs, or to continue an install."
echo "Use './iiab-install --reinstall' to force running all Stages 0-9."
echo "Use './iiab-install --debug' to run Stage 0, followed by Stages 3-9."
echo "Use './runrole' to run a single Stage or Role."
echo "Use './iiab-network' to run Network sections."
echo "Use './iiab-install --reinstall' to force running all Stages 0-9, followed by the Network Role."
echo "Use './iiab-install --debug' to run Stage 0, followed by Stages 3-9, followed by the Network Role."
echo "Use './iiab-configure' to run Stage 0, followed by Stages 4-9."
echo "Use './runrole' to run Stage 0, followed by a single Stage or Role."
echo "Use './iiab-network' to run Stage 0, followed by the Network Role."
exit 1
fi

Expand All @@ -68,9 +70,9 @@ version_gt() { [ "$(printf '%s\n' "$@" | sort -V | head -1)" != "$1" ]; }
# Verify that Raspbian is running a recent enough kernel. As Raspbian
# updates on 4.9.41-v7+ broke bridging, WiFi AP & OpenVPN in Oct/Nov 2017.
CURR_KERN=`uname -r`
echo "Found Kernel "$CURR_KERN""
echo "Found Kernel ""$CURR_KERN"
if [ "$OS" == "raspbian" ] && version_gt $MIN_RPI_KERN $CURR_KERN ; then
echo -e "\nEXITING: Kernel "$MIN_RPI_KERN" or higher required with Raspbian."
echo -e "\nEXITING: Kernel ""$MIN_RPI_KERN"" or higher required with Raspbian."
echo -e "PLEASE RUN 'apt update' then 'apt install raspberrypi-kernel' then reboot."
echo -e "IIAB INSTALL INSTRUCTIONS: https://github.com/iiab/iiab/wiki/IIAB-Installation"
exit 1
Expand All @@ -89,10 +91,10 @@ if [[ `command -v ansible` ]]; then # "command -v" is POSIX compliant; it
#CURR_ANSIBLE_VER=`ansible --version | head -1 | sed -e 's/.* //'`
#CURR_ANSIBLE_VER=`ansible --version | head -1 | cut -f 2 -d " "`
CURR_ANSIBLE_VER=`ansible --version | head -1 | awk '{print $2}'` # to match scripts/ansible
echo "Found Ansible "$CURR_ANSIBLE_VER""
echo "Found Ansible ""$CURR_ANSIBLE_VER"
fi
if version_gt $MIN_ANSIBLE_VER $CURR_ANSIBLE_VER ; then
echo -e "\nEXITING: Ansible "$MIN_ANSIBLE_VER" or higher required.\n"
echo -e "\nEXITING: Ansible ""$MIN_ANSIBLE_VER"" or higher required.\n"

echo -e "REMOVE PRIOR VERSIONS using 'apt purge ansible' and/or 'pip uninstall ansible'."
echo -e "THEN RUN 'scripts/ansible' to install the latest Ansible from PPA or RPM."
Expand All @@ -108,23 +110,19 @@ STAGE=0
if [ -f /etc/iiab/iiab.env ]; then
if grep -q STAGE= /etc/iiab/iiab.env ; then
source /etc/iiab/iiab.env
echo "Extracted STAGE="$STAGE" (counter) from /etc/iiab/iiab.env"
echo "Extracted STAGE=$STAGE (counter) from /etc/iiab/iiab.env"
if ! [ "$STAGE" -eq "$STAGE" ] 2> /dev/null; then
echo -e "\nEXITING: STAGE (counter) value == "$STAGE" is non-integer in /etc/iiab/iiab.env"
echo -e "\nEXITING: STAGE (counter) value == ""$STAGE"" is non-integer in /etc/iiab/iiab.env"
exit 1
elif [ "$STAGE" -lt 0 ] || [ "$STAGE" -gt 9 ]; then
echo -e "\nEXITING: STAGE (counter) value == "$STAGE" is out-of-range in /etc/iiab/iiab.env"
echo -e "\nEXITING: STAGE (counter) value == ""$STAGE"" is out-of-range in /etc/iiab/iiab.env"
exit 1
fi
fi
# if XSCE is present resolveconf will not be
if grep -q XSCE /etc/iiab/iiab.env ; then
STAGE=0
rm /etc/iiab/iiab.env
echo "Removed /etc/iiab/iiab.env effectively resetting STAGE (counter)."
elif [ "$1" == "--reinstall" ]; then

if [ "$1" == "--reinstall" ]; then
STAGE=0
ARGS="$ARGS --extra-vars reinstall=True"
ARGS="$ARGS"" --extra-vars reinstall=True"
sed -i 's/^STAGE=.*/STAGE=0/' /etc/iiab/iiab.env
echo "Wrote STAGE=0 (counter) to /etc/iiab/iiab.env"
elif [ "$STAGE" -ge 2 ] && [ "$1" == "--debug" ]; then
Expand All @@ -133,22 +131,45 @@ if [ -f /etc/iiab/iiab.env ]; then
echo "Wrote STAGE=2 (counter) to /etc/iiab/iiab.env"
elif [ "$STAGE" -eq 9 ]; then
echo -e "\nEXITING: STAGE (counter) in /etc/iiab/iiab.env shows Stage 9 Is Already Done."
echo -e "Use './iiab-install --reinstall' to force running all Stages 0-9."
echo -e "Use './iiab-install --debug' to run Stage 0, followed by Stages 3-9."
echo -e "Use './runrole' to run a single Stage or Role."
echo -e "Use './iiab-network' to run Network sections.\n\n"
exit 0 # allows rerunning http://download.iiab.io/6.7/install.txt
echo -e "Use './iiab-install --reinstall' to force running all Stages 0-9, followed by the Network Role."
echo -e "Use './iiab-install --debug' to run Stage 0, followed by Stages 3-9, followed by the Network Role."
echo -e "Use './iiab-configure' to run Stage 0, followed by Stages 4-9."
echo -e "Use './runrole' to run Stage 0, followed by a single Stage or Role."
echo -e "Use './iiab-network' to run Stage 0, followed by the Network Role.\n\n"

exit 0 # Allows rerunning http://download.iiab.io/install.txt
fi
fi
if [ "$STAGE" -lt 2 ] && [ "$1" == "--debug" ]; then
echo -e "\n'--debug' *ignored* as STAGE (counter) < 2."
fi

# TEMPORARY: Catch images up to current code to benefit from pre-installed apps
if [ -f /etc/iiab/config_vars2.yml ]; then
mv /etc/iiab/config_vars2.yml $IIAB_STATE_FILE
fi

# Assumes /etc/iiab/iiab_state.yml is not created until (prior run of) Stage 4.
if [ -f $IIAB_STATE_FILE ]; then
# Workaround for (web-published) images; will go away later
if grep -q sugar $IIAB_STATE_FILE; && ! grep -q mongodb $IIAB_STATE_FILE; then
echo "mongodb_installed: True" >> $IIAB_STATE_FILE
fi

if [ "$STAGE" -eq 2 ]; then
echo -e "\nCompleting Stage 3 from IIAB image (starts systemd service iiab-setup-db to run the 'mysql' role)."
systemctl start iiab-setup-db
fi

PLAYBOOK="iiab-from-console.yml" # Stage 4-9 then Network Role
ARGS="" # Removes '--extra-vars reinstall=True' if --reinstall, BUT WHY?
fi

echo -e "\nTRY TO RERUN './iiab-install' IF IT FAILS DUE TO CONNECTIVITY ISSUES ETC!\n"

echo -e "Running local playbooks....Stage 0 will now run....followed by Stages $(($STAGE + 1))-9"
echo -e "Running local Ansible playbooks...\n...Stage 0 will now run\n...followed by Stages $(($STAGE + 1))-9\n...and then the Network Role.\n"

export ANSIBLE_LOG_PATH="$CWD/iiab-install.log"
export ANSIBLE_LOG_PATH="$CWD""/iiab-install.log"

ansible -m setup -i $INVENTORY localhost --connection=local >> /dev/null
ansible-playbook -i $INVENTORY $PLAYBOOK ${ARGS} --connection=local
Expand Down
2 changes: 1 addition & 1 deletion iiab-network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- vars/default_vars.yml
- vars/{{ ansible_local.local_facts.os_ver }}.yml
- /etc/iiab/local_vars.yml
- /etc/iiab/config_vars.yml
- /etc/iiab/iiab_state.yml

roles:
- { role: 0-init, tags: ['network'] }
Expand Down
10 changes: 6 additions & 4 deletions roles/4-server-options/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Server Options

- name: ...IS BEGINNING ==================================
command: echo
file:
path: "{{ iiab_state_file }}"
state: touch

- name: Install dnsmasq
include_tasks: roles/network/tasks/dnsmasq.yml
Expand Down Expand Up @@ -31,7 +33,7 @@
- name: Install Bluetooth - only on Raspberry Pi
include_role:
name: bluetooth
when: is_rpi and bluetooth_install
when: (is_rpi and bluetooth_install) or bluetooth_installed is defined
tags: bluetooth

# NETWORK moved to the very end, after Stage 9 (9-LOCAL-ADDONS)
Expand Down Expand Up @@ -66,13 +68,13 @@
- name: CUPS
include_role:
name: cups
when: cups_install | bool
when: cups_install or cups_installed is defined
tags: cups

- name: SAMBA
include_role:
name: samba
when: samba_install | bool
when: samba_install or samba_installed is defined
tags: samba

- name: USB-LIB
Expand Down
10 changes: 0 additions & 10 deletions roles/6-generic-apps/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@
- name: AZURACAST
include_role:
name: azuracast
when: azuracast_install | bool
tags: azuracast

- name: DOKUWIKI
include_role:
name: dokuwiki
when: dokuwiki_install | bool
tags: dokuwiki

- name: MEDIAWIKI
include_role:
name: mediawiki
when: mediawiki_install | bool
tags: mediawiki

- name: EJABBERD
Expand All @@ -30,37 +27,31 @@
- name: ELGG
include_role:
name: elgg
when: elgg_install | bool
tags: elgg

- name: GITEA
include_role:
name: gitea
when: gitea_install | bool
tags: gitea

- name: LOKOLE
include_role:
name: lokole
when: lokole_install | bool
tags: lokole

- name: MOSQUITTO
include_role:
name: mosquitto
when: mosquitto_install | bool
tags: mosquitto

- name: NODE-RED
include_role:
name: nodered
when: nodered_install | bool
tags: nodered

- name: NEXTCLOUD
include_role:
name: nextcloud
when: nextcloud_install | bool
tags: nextcloud

#- name: OWNCLOUD
Expand All @@ -78,7 +69,6 @@
- name: WORDPRESS
include_role:
name: wordpress
when: wordpress_install | bool
tags: wordpress

- name: Recording STAGE 6 HAS COMPLETED ====================
Expand Down
6 changes: 0 additions & 6 deletions roles/7-edu-apps/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,26 @@
- name: KALITE
include_role:
name: kalite
when: kalite_install | bool
tags: kalite

- name: KOLIBRI
include_role:
name: kolibri
when: kolibri_install | bool
tags: kolibri

- name: KIWIX
include_role:
name: kiwix
when: kiwix_install | bool
tags: kiwix

- name: MOODLE
include_role:
name: moodle
when: moodle_install | bool
tags: olpc, moodle

- name: OSM-VECTOR-MAPS
include_role:
name: osm-vector-maps
when: osm_vector_maps_install | bool
tags: osm, maps

# UNMAINTAINED
Expand All @@ -50,7 +45,6 @@
- name: SUGARIZER
include_role:
name: sugarizer
when: sugarizer_install | bool
tags: sugarizer

- name: Recording STAGE 7 HAS COMPLETED ========================
Expand Down
Loading