├── LICENSE ├── README.md ├── at-splash-640x400-32.fb ├── boot-part-2.sh ├── boot.sh ├── cleanup.sh ├── make-data-disk.sh ├── say-hello.sh ├── warrior-install.sh └── warrior-runner.sh /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | warrior-code2 2 | ============= 3 | 4 | Boot scripts for the ArchiveTeam Warrior 2 5 | 6 | See the [Archive Team Warrior wiki page](http://archiveteam.org/index.php?title=Warrior) for more information. 7 | -------------------------------------------------------------------------------- /at-splash-640x400-32.fb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArchiveTeam/warrior-code2/cc602d48fe38ddb9322965ccb813158ab0a80c79/at-splash-640x400-32.fb -------------------------------------------------------------------------------- /boot-part-2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # A small boot script. 3 | # Prepares and runs the warrior. 4 | # This script starts after boot.sh has updated the code. 5 | 6 | stop() { 7 | while true 8 | do 9 | sleep 120 10 | done 11 | } 12 | ./warrior-install.sh 13 | 14 | if [ -n "$DOCKER" ] 15 | then 16 | sudo mkdir -p /data/data && sudo chown -R warrior: /data 17 | else 18 | sudo ./make-data-disk.sh 19 | fi 20 | 21 | mkdir -p /home/warrior/projects 22 | 23 | touch /dev/shm/ready-for-warrior 24 | 25 | ./say-hello.sh 26 | 27 | if [ -z "$DOCKER" ] 28 | then 29 | stop 30 | fi 31 | 32 | -------------------------------------------------------------------------------- /boot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # A small boot script. 3 | # Pulls the latest code from GitHub, then runs boot-part-2.sh. 4 | 5 | stop() { 6 | while true 7 | do 8 | sleep 120 9 | done 10 | } 11 | 12 | cd /home/warrior/warrior-code2 13 | echo 14 | echo " ****************************************************************" 15 | echo " * *" 16 | echo " * Welcome to the ArchiveTeam Warrior *" 17 | echo " * *" 18 | echo " * www.archiveteam.org *" 19 | echo " * *" 20 | echo " ****************************************************************" 21 | echo 22 | echo " The Warrior Code is launching. Please wait..." 23 | echo 24 | echo "Loading the ArchiveTeam Warrior..." 25 | echo "Updating the warrior code..." 26 | 27 | tries=5 28 | delay=1 29 | err=false 30 | while [[ $tries -gt 0 ]] 31 | do 32 | if git pull 33 | then 34 | tries=0 35 | err=false 36 | else 37 | echo 38 | echo "Waiting for a network connection..." 39 | sleep $delay 40 | 41 | tries=$(( tries - 1 )) 42 | delay=$(( delay * 2 )) 43 | err=true 44 | fi 45 | done 46 | 47 | if $err 48 | then 49 | echo 50 | echo "ERROR: Could not update the code. Is your network connection OK?" 51 | echo "Reboot the machine and try again." 52 | stop 53 | fi 54 | 55 | git show --quiet --pretty="format:Warrior version %h -- %cr" | head -n 1 56 | echo 57 | echo 58 | 59 | ./boot-part-2.sh 60 | 61 | -------------------------------------------------------------------------------- /cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -rf /var/cache/apt/* \ 3 | /var/cache/debconf/* \ 4 | /var/lib/apt/* \ 5 | /var/lib/aptitude/* \ 6 | /var/log/* \ 7 | /usr/share/aptitude/* \ 8 | /usr/share/doc/* \ 9 | /usr/share/man/* 10 | 11 | find /usr/share/locale/ -mindepth 1 -maxdepth 1 -type d ! -name "en*" -exec rm -rf {} \; 12 | 13 | chmod 777 /data 14 | 15 | # echo "Zero-filling /data" 16 | # dd if=/dev/zero of=/data/fill bs=10M 17 | # rm -f /data/fill 18 | 19 | echo "Zero-filling /" 20 | dd if=/dev/zero of=/root/fill bs=10M 21 | rm -f /root/fill 22 | 23 | -------------------------------------------------------------------------------- /make-data-disk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script looks for an unmounted disk where 3 | # it can create a partition. It formats the partition 4 | # and mounts it on /data. 5 | # 6 | # This is faster than rm -rf /data/ and allows the user 7 | # to connect a new, unformatted disk to the warrior VM. 8 | 9 | # unmount the partition 10 | if grep -qs " /data " /proc/mounts ; then 11 | umount /data 12 | fi 13 | 14 | # find an unmounted disk 15 | root_disk=$( mount -l | grep " on / " | cut -d " " -f 1 | grep -o "sd." ) 16 | data_disk=$( ls -1 /dev/sd? | grep -v $root_disk | head -n 1 ) 17 | 18 | # reset partition table 19 | echo "Creating a data partition on ${data_disk}..." 20 | ( echo d ; echo d ; echo d ; echo d ; echo d ; echo n ; echo p ; echo 1 ; echo ; echo ; echo w ) | fdisk $data_disk &> /dev/null 21 | 22 | # format drive, mount and prepare folders 23 | echo "Preparing the data partition..." 24 | mke2fs -t ext4 -O ^has_journal -E lazy_itable_init=1 ${data_disk}1 &> /dev/null 25 | mount -t ext4 -o noatime,nodiratime,data=writeback,barrier=0,nobh ${data_disk}1 /data 26 | mkdir /data/data 27 | chmod 777 /data /data/data 28 | 29 | echo "...Done." 30 | -------------------------------------------------------------------------------- /say-hello.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | tput civis 4 | stty -echo 5 | 6 | # On VirtualBox we have port forwarding from localhost on the host, 7 | # but VMware doesn't do that. 8 | IP_ADDRESS=$( ifconfig eth0 | grep -oP "inet addr:[.0-9]+" | grep -oP "[.0-9]+" ) 9 | SYSTEM=$( lspci | grep -i system ) 10 | 11 | echo -e "\033[0;30;47m" 12 | echo 13 | echo " The warrior has successfully started up." 14 | echo 15 | 16 | if [[ $SYSTEM =~ VirtualBox ]] 17 | then 18 | echo " Point your web browser to http://localhost:8001/ to manage your warrior." 19 | sudo sh -c "cat at-splash-640x400-32.fb > /dev/fb0" 20 | else 21 | echo " Point your web browser to http://${IP_ADDRESS}:8001/ to manage your warrior." 22 | bytes=$(( 640 * 355 * 4 )) 23 | sudo sh -c "cat at-splash-640x400-32.fb | head -c $bytes > /dev/fb0" 24 | fi 25 | 26 | echo -ne "\033[0;00;00m" 27 | 28 | -------------------------------------------------------------------------------- /warrior-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script should install/update the warrior, if necessary. 3 | 4 | PIP=pip 5 | REBOOT_NEEDED=false 6 | 7 | if type pip3 > /dev/null 2>&1; then 8 | PIP=pip3 9 | fi 10 | 11 | echo "Using '$PIP' for pip." 12 | 13 | 14 | # Upgrade pip for 2012 warriors 15 | if pip --version | grep "pip 1.2.1 from /usr/local/lib/python2.6/dist-packages"; then 16 | echo "Upgrading pip..." 17 | 18 | mkdir -p /tmp/pip/ 19 | curl http://warriorhq.archiveteam.org/downloads/pip/get-pip.py > /tmp/pip/get-pip.py 20 | curl http://warriorhq.archiveteam.org/downloads/pip/sha1sum.txt > /tmp/pip/sha1sum.txt 21 | grep get-pip.py /tmp/pip/sha1sum.txt > /tmp/pip/sha1sum_get_pip.txt 22 | 23 | if (cd /tmp/pip/ && sha1sum --check sha1sum_get_pip.txt); then 24 | sudo python /tmp/pip/get-pip.py 25 | echo "Reinstalling seesaw..." 26 | sudo pip install seesaw --ignore-installed 27 | REBOOT_NEEDED=true 28 | else 29 | echo "Pip download could not be validated!" 30 | echo "You may need to inspect the problem and reboot manually." 31 | echo "Pausing for 60 seconds before continuing..." 32 | sleep 60 33 | fi 34 | fi 35 | 36 | 37 | # Upgrade old setuptools to fix DistributionNotFound after new pip install 38 | if python --version 2>&1 | grep "Python 2." && 39 | python -c "import setuptools; print 'v'+setuptools.__version__" | grep "v0.6" 40 | then 41 | echo "Upgrading setuptools..." 42 | sudo pip install setuptools --upgrade 43 | REBOOT_NEEDED=true 44 | fi 45 | 46 | 47 | if "$REBOOT_NEEDED"; then 48 | echo "Done! Rebooting in 60 seconds..." 49 | sudo shutdown -r 1 50 | fi 51 | 52 | # Check the seesaw-kit. 53 | echo "Checking for the latest seesaw kit..." 54 | if [ -z "$DOCKER" ] 55 | then 56 | seesaw_branch=$( git rev-parse --abbrev-ref HEAD ) 57 | else 58 | seesaw_branch=master 59 | fi 60 | SEESAW_VERSION=$( git ls-remote https://github.com/ArchiveTeam/seesaw-kit.git ${seesaw_branch} | cut -f 1 ) 61 | if ! sudo $PIP freeze | grep -q $SEESAW_VERSION 62 | then 63 | echo "Upgrading the seesaw kit..." 64 | if ! sudo $PIP install -e "git+https://github.com/ArchiveTeam/seesaw-kit.git@${seesaw_branch}#egg=seesaw" --upgrade 65 | then 66 | # sometimes pip's git pull fails because the local repository 67 | # is invalid. reset and try again 68 | sudo rm -rf "/home/warrior/warrior-code2/src/seesaw" 69 | sudo $PIP install -e "git+https://github.com/ArchiveTeam/seesaw-kit.git@${seesaw_branch}#egg=seesaw" --upgrade 70 | fi 71 | else 72 | echo "No need to upgrade the seesaw kit." 73 | fi 74 | 75 | # Check for splash screen support. 76 | if [ ! -f /etc/modprobe.d/uvesafb.conf ] && [ -z "$DOCKER" ] 77 | then 78 | echo "Installing framebuffer..." 79 | sudo apt-get update 80 | sudo apt-get -y install v86d 81 | sudo sh -c 'echo "uvesafb" >> /etc/modules' 82 | sudo sh -c 'echo "options uvesafb mode_option=640x400-32 scroll=ywrap" > /etc/modprobe.d/uvesafb.conf' 83 | sudo modprobe uvesafb 84 | fi 85 | 86 | # Remove the old /data mount settings 87 | if [ -z "$DOCKER" ] 88 | then 89 | if grep -qs "/dev/sdb1 /data" /etc/fstab 90 | then 91 | echo "Disabling /data auto-mount..." 92 | sudo sed --in-place -r "s/\/dev\/sdb1 \/data ext3 noatime 0 0//" /etc/fstab 93 | fi 94 | fi 95 | 96 | # Install DNS caching 97 | if [ ! -f /etc/dnsmasq.conf ] 98 | then 99 | sudo apt-get update 100 | sudo apt-get -y install dnsmasq 101 | sudo sh -c 'echo "listen-address=127.0.0.1" > /etc/dnsmasq.conf' 102 | sudo sed --in-place -r "s/^#prepend domain-name-servers 127.0.0.1;/prepend domain-name-servers 127.0.0.1;/" /etc/dhcp/dhclient.conf 103 | if [ -z "$DOCKER" ]; then sudo dhclient; fi 104 | sudo /etc/init.d/dnsmasq restart 105 | fi 106 | 107 | # Fix a mistake with relative filenames 108 | rm -rf /home/warrior/warrior-code2/data 109 | 110 | # Disable mlocate 111 | sudo rm -f /etc/cron.daily/mlocate 112 | -------------------------------------------------------------------------------- /warrior-runner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | WARRIOR=run-warrior2 4 | 5 | if type python3 > /dev/null 2>&1 && type run-warrior3 > /dev/null 2>&1 ; then 6 | WARRIOR=run-warrior3 7 | fi 8 | 9 | while [ ! -f /dev/shm/ready-for-warrior ] 10 | do 11 | sleep 1 12 | done 13 | 14 | cd /home/warrior/warrior-code2 15 | 16 | $WARRIOR \ 17 | --projects-dir /home/warrior/projects \ 18 | --data-dir /data/data \ 19 | --warrior-hq https://warriorhq.archiveteam.org \ 20 | --port 8001 \ 21 | --real-shutdown 22 | --------------------------------------------------------------------------------