Last active
March 3, 2016 23:11
-
-
Save Jaesin/e563ff16df5f54a93ec2 to your computer and use it in GitHub Desktop.
Zeepro Zim provisioning bash script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script is for initializing a zim and installing a pre-compiled version of octoprint. | |
# Run as root. If using sudo, use "sudo -i -u root" | |
echo "Making root writable" | |
mount -o remount,rw / | |
echo "Add some aliases for root." | |
cat >>/root/.bashrc <<EOL | |
alias lsa="ls -hal --color" | |
alias ro="mount -o remount,ro /" | |
alias rw="mount -o remount,rw /" | |
alias stop-fw="service fw-upgrade stop" | |
EOL | |
echo "Add debian linux sources." | |
cat >/etc/apt/sources.list.d/debian.list <<EOL | |
# wheezy | |
deb http://ftp.de.debian.org/debian wheezy main contrib non-free | |
deb-src http://ftp.de.debian.org/debian wheezy main contrib non-free | |
# wheezy-updates | |
deb http://ftp.debian.org/debian/ wheezy-updates main contrib non-free | |
deb-src http://ftp.debian.org/debian/ wheezy-updates main contrib non-free | |
# wheezy/updates | |
deb http://security.debian.org/ wheezy/updates main contrib non-free | |
deb-src http://security.debian.org/ wheezy/updates main contrib non-free | |
# wheezy-backports | |
deb http://ftp.de.debian.org/debian wheezy-backports main contrib non-free | |
deb-src http://ftp.de.debian.org/debian wheezy-backports main contrib non-free | |
EOL | |
echo "Update APT (this will take a bit)." | |
apt-get update | |
echo "Installing Python 2.7" | |
apt-get install -y python screen | |
echo "Creating the zim user." | |
adduser --gecos "" zim && adduser zim tty && adduser zim sudo && adduser zim dialout | |
echo "Creating the octoprint config folder." | |
mkdir -p /config/octoprint && chown -R zim:zim /config/octoprint | |
su -c "ln -s /config/octoprint /home/zim/.octoprint " zim | |
echo "Downloading precompiled octoprint." | |
wget -qO- /usr/ https://www.dropbox.com/s/ihuqbnmi2b9xrkt/oprint_zim-1.2.9.tar.bz2 | tar -xjv -C /usr/local/share | |
chown -R zim:zim /usr/local/share/oprint | |
echo "Copy the init file and fix the networking requirement." | |
sed '5s/# Required-Start.*/# Required-Start: $local_fs $network/' /usr/local/share/oprint/scripts/octoprint.init > /etc/init.d/octoprint | |
echo "Make the init script executable." | |
chmod +x /etc/init.d/octoprint | |
echo "Creating the octoprint service configuration file." | |
cat >/etc/default/octoprint <<EOL | |
# Configuration for /etc/init.d/octoprint | |
# The init.d script will only run if this variable non-empty. | |
OCTOPRINT_USER=zim | |
# On what port to run daemon, default is 5000 | |
PORT=5000 | |
# Path to the OctoPrint executable, use this to override the default setting "/usr/bin/octoprint" | |
DAEMON=/usr/local/share/oprint/venv/bin/octoprint | |
# What arguments to pass to octoprint, usually no need to touch this | |
DAEMON_ARGS="--port=\$PORT" | |
# Umask of files octoprint generates, Change this to 000 if running octoprint as its own, separate user | |
UMASK=022 | |
# Process priority, 0 here will result in a priority 20 process. | |
# -2 ensures Octoprint has a slight priority over user processes. | |
NICELEVEL=-2 | |
# Should we run at startup? | |
START=yes | |
EOL | |
# Update to the default service levels. | |
update-rc.d octoprint defaults | |
echo "It's time to reboot your zim and test http://zim.local:5000" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment