Last active
March 19, 2016 06:22
-
-
Save Jaesin/2b93440cadcc0fb5702f to your computer and use it in GitHub Desktop.
Zeepro zim Install OctoPrint
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 | |
# Run as root. If using sudo, use "sudo -i -u root" | |
# This script is for building octoprint on a zim cubieboard. | |
# I have since moved to building a binary version of octoprint in an armhf qemu vm. | |
# I am using a build virtual machine to build octoprint. Qemu immulates armhf and | |
# is used to hostthe build machine. | |
# | |
# Debian Wheezy armhf images were obtained from: https://people.debian.org/~aurel32/qemu/armhf/ | |
### Run on your Mac ### | |
####################### | |
brew install qemu aria2 | |
# Create the vm folder: | |
mkdir -p ~/Virtual\ Machines/QEMU/armhf/ | |
cd ~/Virtual\ Machines/QEMU/armhf/ | |
# | |
# Aria2 helps bring down the images faster. | |
aria2c -x 16 https://people.debian.org/\~aurel32/qemu/armhf/debian_wheezy_armhf_standard.qcow2 | |
aria2c -x 16 https://people.debian.org/\~aurel32/qemu/armhf/vmlinuz-3.2.0-4-vexpress | |
aria2c -x 16 https://people.debian.org/\~aurel32/qemu/armhf/initrd.img-3.2.0-4-vexpress | |
# | |
# Start the vm: | |
qemu-system-arm -M vexpress-a9 -m 1024MiB -kernel vmlinuz-3.2.0-4-vexpress -initrd initrd.img-3.2.0-4-vexpress -drive if=sd,file=debian_wheezy_armhf_standard.qcow2 -append "root=/dev/mmcblk0p2" -net nic -net user -redir tcp:2222::22 & | |
# | |
# ssh into your build vm as root. The password will also be root: | |
ssh -p 2222 root@localhost | |
### END run on your Mac ### | |
########################### | |
### Build on a build machine ### | |
################################ | |
# Install requirements for building OctoPrint. | |
apt-get install git python python-dev python-pip python-setuptools python-virtualenv | |
mkdir -p /usr/local/share | |
# Retrieve the OctoPrint source. | |
git clone https://github.com/foosel/OctoPrint.git /usr/local/share/oprint && cd /usr/local/share/oprint | |
# Checkout the latest release tag. | |
git checkout 1.2.10 | |
# Set up the virtual environment. | |
virtualenv venv | |
# Install an older version of bable because Bable 2.2 (User for translation) is broken. | |
./venv/bin/pip install Babel==2.1.1 | |
# Build octoprint. | |
./venv/bin/python setup.py install | |
# Create a distributable tar file. | |
tar --exclude='.git' -C ../ -cjvf ../oprint_zim-1.2.10.tar.bz2 oprint | |
# Build uploaded to https://www.dropbox.com/s/ihuqbnmi2b9xrkt/oprint_zim-1.2.9.tar.bz2?dl=0 | |
### END Build on a build machine ### | |
#################################### | |
# Make sure the root partition is writable. | |
mount -o remount,rw / | |
# Install requirements for building OctoPrint. | |
apt-get install git python python-dev python-pip python-setuptools python-virtualenv | |
# Create a local share folder. | |
mkdir -p /usr/local/share | |
# Retrieve the OctoPrint source. | |
git clone https://github.com/foosel/OctoPrint.git /usr/local/share/oprint && cd /usr/local/share/oprint | |
# Checkout the latest release tag. | |
git checkout 1.2.8 | |
# Set up the virtual environment | |
virtualenv venv | |
# Build OctoPrint # | |
################### | |
# Install an older version of bable because Bable 2.2 (User for translation) is broken. | |
./venv/bin/pip install Babel==2.1.1 | |
# Build octoprint. | |
./venv/bin/python setup.py install | |
# Create the OctoPrint config folder. | |
mkdir -p /config/octoprint | |
# Link it to the zime users default location. | |
ln -s /config/octoprint /home/zim/.octoprint | |
# Make zim the owner of all things OctoPrint. | |
chown -R zim:zim /var/www/oprint /config/octoprint /home/zim/.octoprint | |
echo 'Now you can log in with the zim user and use "/var/www/oprint/run" to start OctoPrint for testing.' | |
# Copy the init file and fix the networking requirement. | |
sed '5s/# Required-Start.*/# Required-Start: $local_fs $network/' /var/www/oprint/scripts/octoprint.init > /etc/init.d/octoprint | |
# Make the init script executable. | |
chmod +x /etc/init.d/octoprint | |
# Create 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=/var/www/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