Skip to content

Commit

Permalink
Move nems-www to repository
Browse files Browse the repository at this point in the history
  • Loading branch information
NEMS Linux committed Apr 21, 2021
1 parent a0c6062 commit 392fe24
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 162 deletions.
4 changes: 2 additions & 2 deletions build/000-git
Expand Up @@ -3,8 +3,8 @@
# Ensure git is installed before proceeding with build

if [[ ! -e /usr/bin/git ]]; then
apt update
apt -y install git
apt-get update
apt-get -y install git
fi


13 changes: 0 additions & 13 deletions build/000-repository

This file was deleted.

49 changes: 0 additions & 49 deletions build/001-nems-www
@@ -1,51 +1,2 @@
#!/bin/bash

# Web Interface
cd /var/www

git clone https://github.com/Cat5TV/nems-www

useradd www-data
chown -R www-data:www-data nems-www

# Detect if the snapshot folder is mounted (which means this is Docker)
if [[ -e /var/www/html/backup/snapshot/ ]]; then
# Docker, so rsync instead of replace
apt-get update
apt-get install -y rsync
rsync -a nems-www/. html/
rm -rf nems-www
# Remove the Apache placeholder
if [[ -e /var/www/html/index.html ]]; then
rm -f /var/www/html/index.html
fi
else
# All other platforms (not Docker)
if [[ -d html ]]; then
rm -rf html
fi
mv nems-www html
fi

# NEMS-SST will need access to a few things
if ! grep -q "# nems-www" /etc/sudoers; then
echo '
# nems-www' | sudo EDITOR='tee -a' visudo
fi

if ! grep -q "www-data ALL=NOPASSWD: /usr/bin/htpasswd" /etc/sudoers; then
echo 'www-data ALL=NOPASSWD: /usr/bin/htpasswd' | sudo EDITOR='tee -a' visudo
fi

if [[ -e /sbin/reboot ]]; then
if ! grep -q "www-data ALL=NOPASSWD: /sbin/reboot" /etc/sudoers; then
echo 'www-data ALL=NOPASSWD: /sbin/reboot' | sudo EDITOR='tee -a' visudo
fi
fi

if [[ -e /sbin/shutdown ]]; then
if ! grep -q "www-data ALL=NOPASSWD: /sbin/shutdown" /etc/sudoers; then
echo 'www-data ALL=NOPASSWD: /sbin/shutdown' | sudo EDITOR='tee -a' visudo
fi
fi

4 changes: 4 additions & 0 deletions build/001-packages
@@ -0,0 +1,4 @@
#!/bin/bash
9590
nems-www

25 changes: 1 addition & 24 deletions build/035-apache2
@@ -1,5 +1,5 @@
a2enmod ssl
#!/bin/bash
echo $0 > /var/www/html/userfiles/nems-build.cur

if [[ $ver == '' ]]; then
if [[ -e /usr/local/bin/nems-info ]]; then
Expand All @@ -9,26 +9,3 @@ if [[ $ver == '' ]]; then
fi
fi

a2enmod ssl
apt -y install ssl-cert libapache2-mod-security2

# Generating new Snakeoil cert
/usr/sbin/make-ssl-cert generate-default-snakeoil --force-overwrite

/bin/systemctl stop apache2
cp -f /root/nems/nems-migrator/data/1.5/apache2/sites-available/nems-dashboard.conf /etc/apache2/sites-available

a2dissite 000-default
a2ensite nems-dashboard

a2enmod rewrite

# Change Apache footer
a2enmod security2
a2enconf security
/bin/sed -i~ '/SecServerSignature/d' /etc/apache2/conf-available/security.conf
echo "SecServerSignature NEMS_Linux/$ver" >> /etc/apache2/conf-available/security.conf

/bin/systemctl start apache2

exit 0
60 changes: 0 additions & 60 deletions build/036-php

This file was deleted.

6 changes: 6 additions & 0 deletions build/packages.base
Expand Up @@ -52,3 +52,9 @@ grub2-common
#firmware-linux-nonfree
ssh
less

# NEMS Linux 1.6+
9590
nems-www
wmic

38 changes: 24 additions & 14 deletions nems-build.sh
Expand Up @@ -23,6 +23,16 @@ if [[ ! -d /var/log/nems ]]; then
mkdir /var/log/nems
fi

# Add NEMS Linux Repositories
echo "# NEMS Linux 1.6 Repositories
deb https://nemslinux.com/repos/apt/nems/ 1.6 main
deb https://nemslinux.com/repos/apt/nems/ 1.6 migrator
deb https://nemslinux.com/repos/apt/nems/ 1.6 plugins" > /etc/apt/sources.list.d/nemslinux.list

# Add the public key [expires: 2023-04-20]
wget -O - https://nemslinux.com/nemslinux.gpg.key | apt-key add -


# If /sbin is not in PATH, add it (eg., halt, reboot)
if [[ ! $PATH == *"/sbin"* ]]; then
export PATH=$PATH:/sbin
Expand Down Expand Up @@ -108,15 +118,15 @@ df -hT /etc
sleep 5

# Remove cruft
apt update
apt -y --allow-remove-essential clean
apt -y --allow-remove-essential --purge remove $(grep -vE "^\s*#" build/packages.remove | tr "\n" " ")
apt autoremove --purge -y
apt-get update
apt-get -y --allow-remove-essential clean
apt-get -y --allow-remove-essential --purge remove $(grep -vE "^\s*#" build/packages.remove | tr "\n" " ")
apt-get autoremove --purge -y
rm -R /usr/share/fonts/*
rm -R /usr/share/icons/*

# Fix any broken packages to allow installation to occur in next step
apt -y --fix-broken install
apt-get -y --fix-broken install

echo "Usage after cruft removal:"
df -hT /etc
Expand All @@ -125,31 +135,31 @@ sleep 5
# Install base packages
for pkg in $(grep -vE "^\s*#" build/packages.base | tr "\n" " ")
do
apt -y --no-install-recommends install $pkg
apt-get -y --no-install-recommends install $pkg
if [ $(dpkg-query -W -f='${Status}' $pkg 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
# It still isn't showing as installed after attempting, so try again
sleep 15
apt -y --no-install-recommends install $pkg
apt-get -y --no-install-recommends install $pkg
fi
done

# Add packages from repositories
for pkg in $(grep -vE "^\s*#" build/packages.add | tr "\n" " ")
do
apt -y --no-install-recommends install $pkg
apt-get -y --no-install-recommends install $pkg
if [ $(dpkg-query -W -f='${Status}' $pkg 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
# It still isn't showing as installed after attempting, so try again
sleep 15
apt -y --no-install-recommends install $pkg
apt-get -y --no-install-recommends install $pkg
fi
done

# Install dependencies, if any
apt -y install -f
apt-get -y install -f

# Be up to date
apt update
apt -y upgrade
# Be up to update
apt-get update
apt-get -y upgrade

# Disable firstrun (ARMbian)
if [[ -e /etc/init.d/firstrun ]]; then
Expand Down Expand Up @@ -180,7 +190,7 @@ echo ""
# Final cleanup...

cd /tmp
apt -y autoremove
apt-get -y autoremove

echo "Usage after build:"
df -hT /etc
Expand Down

0 comments on commit 392fe24

Please sign in to comment.