├── .gitignore ├── LICENSE ├── README.rst ├── build.sh └── delivery ├── files ├── 55-udisks.pkla ├── bashrc ├── config.yaml ├── spreadpi.service ├── spreadpi_init └── spreads.service └── scripts ├── 00-update.sh ├── 01-locales.sh ├── 02-firmware.sh ├── 02-network.sh ├── 03-tools.sh ├── 04-users.sh ├── 05-udev.sh ├── 07-date.sh ├── 07-firstboot.sh ├── 08-udisks.sh └── 10-spreads.sh /.gitignore: -------------------------------------------------------------------------------- 1 | buildlog.txt 2 | spreadpi.img 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | .. image:: https://raw.githubusercontent.com/DIYBookScanner/spreadpi/gh-pages/logo_small.jpg 2 | 3 | Raspberry Pi image tailored for running a DIYBookScanner with the spreads 4 | software suite. 5 | 6 | Based on a script by Andrius Kairiukstis and Klaus M. Pfeiffer: 7 | https://github.com/andrius/build-raspbian-image 8 | 9 | Download 10 | ======== 11 | `Latest Nightly Build `_ 12 | 13 | For older versions, head over to the `Buildbot directory `_. 14 | 15 | Build Requirements 16 | ================== 17 | * `git` 18 | * `binfmt_misc` kernel module loaded 19 | * `qemu-arm-static` 20 | * `deboostrap` 21 | * `kpartx` 22 | * `mkfs.vfat` 23 | * `mkfs.ext4` 24 | * `dmsetup` 25 | * raspbian archive key installed 26 | 27 | On Debian and derivatives:: 28 | 29 | wget http://archive.raspbian.org/raspbian.public.key -O - | sudo apt-key add - 30 | 31 | Building 32 | ======== 33 | To generate an image, run the `build.sh` script as root: 34 | 35 | :: 36 | 37 | $ sudo ./build.sh 38 | 39 | There are some environment variables that you can set to customize the build: 40 | 41 | `IMAGESIZE` 42 | Target size for the image in MB (default: `2000`) 43 | `BOOTSIZE` 44 | Size of the `/boot` partition in MB (default: `64`) 45 | `DEB_RELEASE` 46 | Target Raspbian release, can be `stable`, `testing` or `unstable` (default: `stable`) 47 | `DEFAULT_DEB_MIRROR` 48 | Repository URL to grab packages from (default: `http://mirrordirector.raspbian.org/raspbian`) 49 | `USE_LOCAL_MIRROR` 50 | For use with `apt-cacher-ng`, can be `true` or `false` (default: `false`) 51 | `SSH_KEY` 52 | Public key to enable SSH Login for (default: `~/.ssh/id_rsa.pub`) 53 | `DEBUG` 54 | Drop into a chroot shell after the image has finished building (default: `false`) 55 | `FROM_TARBALL` 56 | Path to a spreads tarball created by ``python setup.py sdist``. If unset, install from Raspbian packages. 57 | 58 | The image will generate a rasbpian image with up-to-date packages and spreads 59 | pre-installed and pre-configured (for use with Canon A2200 cameras running CHDK). 60 | On the first boot, the image will resize itself to fill all of the remaining space 61 | on the SD-Card and reboot shortly thereafter. 62 | Spreads will be automatically launched on startup. Make sure that your devices 63 | are turned on before the boot has finished. 64 | 65 | Login accounts: 66 | * root:raspberry 67 | * spreads:spreads 68 | 69 | The `spreads` user is allowed to run all commands with superuser privileges through `sudo`. 70 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Exit on errors 4 | ORIG_DIR=$(pwd) 5 | set -e 6 | function print_info() 7 | { 8 | green='\e[0;32m' 9 | endColor='\e[0m' 10 | echo -e "${green}=> $1${endColor}" 11 | if [[ -n "$LOG" && -f "$LOG" ]]; then 12 | echo "=> $1" >> "$LOG" 13 | fi 14 | } 15 | 16 | function print_error() 17 | { 18 | red='\e[0;31m' 19 | endColor='\e[0m' 20 | echo -e "${red}!!> $1${endColor}" 21 | if [[ -n "$LOG" && -f "$LOG" ]]; then 22 | echo "!!> $1" >> "$LOG" 23 | fi 24 | } 25 | 26 | function cleanup() 27 | { 28 | set +e 29 | 30 | EXIT_AFTER=false 31 | if [ ! -z "$1" ] && [ "$1" == "-clean" ]; then 32 | print_info "Cleaning up" 33 | else 34 | print_error "Error occurred! Read $LOG for details." 35 | if $DEBUG && $CHROOT_READY; then 36 | LANG=C chroot ${rootfs} /bin/bash 37 | fi 38 | EXIT_AFTER=true 39 | print_info "Cleaning up" 40 | fi 41 | # Make sure we're not in the mounted filesystem anymore, or unmount -l would silently keep waiting! 42 | print_info "Change working directory to $ORIG_DIR..." 43 | cd $ORIG_DIR 44 | 45 | # Unmount 46 | if [ ! -z ${bootp} ]; then 47 | umount -l ${bootp} &>> $LOG 48 | fi 49 | umount -l ${rootfs}/usr/src/delivery &>> $LOG 50 | umount -l ${rootfs}/dev/pts &>> $LOG 51 | umount -l ${rootfs}/dev &>> $LOG 52 | umount -l ${rootfs}/sys &>> $LOG 53 | umount -l ${rootfs}/proc &>> $LOG 54 | umount -l ${rootfs} &>> $LOG 55 | if [ ! -z ${rootp} ]; then 56 | umount -l ${rootp} &>> $LOG 57 | fi 58 | 59 | # Remove build directory 60 | if [ ! -z "$BUILD_ENV" ]; then 61 | print_info "Remove directory $BUILD_ENV ..." 62 | rm -rf "$BUILD_ENV" 63 | fi 64 | 65 | # Remove partition mappings 66 | if [ ! -z ${lodevice} ]; then 67 | print_info "remove $lodevice ..." 68 | kpartx -vd ${lodevice} &>> $LOG 69 | losetup -d ${lodevice} &>> $LOG 70 | fi 71 | 72 | if [ $EXIT_AFTER = true ]; then 73 | exit 1 74 | fi 75 | } 76 | 77 | 78 | if [ ${EUID} -ne 0 ]; then 79 | print_error "this tool must be run as root" 80 | exit 1 81 | fi 82 | 83 | # When true, script will drop into a chroot shell at the end to inspect the 84 | # bootstrapped system 85 | if [ -z "$DEBUG" ]; then 86 | DEBUG=false 87 | fi 88 | 89 | 90 | # =================== # 91 | # CONFIGURATION # 92 | # =================== # 93 | 94 | # Size of target SD card in MB 95 | if [ -z "$IMAGESIZE" ]; then 96 | IMAGESIZE="2000" 97 | fi 98 | # Size of /boot partition 99 | if [ -z "$BOOTSIZE" ]; then 100 | BOOTSIZE="64M" 101 | fi 102 | # Debian version 103 | if [ -z "$DEB_RELEASE" ]; then 104 | DEB_RELEASE="stable" 105 | fi 106 | if [ -z "$DEFAULT_DEB_MIRROR" ]; then 107 | DEFAULT_DEB_MIRROR="http://mirrordirector.raspbian.org/raspbian" 108 | fi 109 | # Whether to use a local debian mirror (e.g. via 'apt-cacher-ng') 110 | if [ -z "$USE_LOCAL_MIRROR" ]; then 111 | USE_LOCAL_MIRROR=false 112 | fi 113 | if [ -z "$LOCAL_DEB_MIRROR" ]; then 114 | LOCAL_DEB_MIRROR="http://localhost:3142/archive.raspbian.org/raspbian" 115 | fi 116 | 117 | # Path to authorized SSH key, exported for scripts/04-users 118 | if [ -z "$SSH_KEY" ]; then 119 | SSH_KEY="~/.ssh/id_rsa.pub" 120 | fi 121 | export SSH_KEY 122 | 123 | if [ -z "$RASBIAN_KEY_URL" ]; then 124 | RASBIAN_KEY_URL="http://archive.raspbian.org/raspbian.public.key" 125 | fi 126 | 127 | # -------------------------------------------------------------------------- # 128 | 129 | # Path to build directory, by default a temporary directory 130 | 131 | # Register cleanup function to run before we exit 132 | trap cleanup EXIT 133 | 134 | print_info "Creating temporary directory..." 135 | BUILD_ENV=$(mktemp -d) 136 | print_info "Temporary directory created at $BUILD_ENV" 137 | 138 | BASE_DIR="$(dirname $0)" 139 | SCRIPT_DIR="$(readlink -m $BASE_DIR)" 140 | LOG="${SCRIPT_DIR}/buildlog.txt" 141 | IMG="${SCRIPT_DIR}/spreadpi.img" 142 | DELIVERY_DIR="$SCRIPT_DIR/delivery" 143 | rootfs="${BUILD_ENV}/rootfs" 144 | bootfs="${rootfs}/boot" 145 | QEMU_ARM_STATIC="/usr/bin/qemu-arm-static" 146 | CHROOT_READY=false 147 | 148 | if [ -e $IMG ]; then 149 | print_error "spreadpi.img already exists, please remove it before running the script." 150 | exit 1 151 | fi 152 | 153 | if [ -n "$FROM_TARBALL" ]; then 154 | cp $FROM_TARBALL $DELIVERY_DIR/spreads-sdist.tar.gz 155 | print_info "Installing from tarball $FROM_TARBALL" 156 | fi 157 | 158 | # Exported to subshells 159 | export DELIVERY_DIR 160 | 161 | print_info "Creating log file $LOG" 162 | rm -f $LOG 163 | touch "$LOG" 164 | chmod a+r "$LOG" 165 | 166 | if $USE_LOCAL_MIRROR; then 167 | DEB_MIRROR=$LOCAL_DEB_MIRROR 168 | else 169 | DEB_MIRROR=$DEFAULT_DEB_MIRROR 170 | fi 171 | print_info "Using mirror $DEB_MIRROR" 172 | 173 | # Create build dir 174 | print_info "Create directory $BUILD_ENV" 175 | mkdir -p "${BUILD_ENV}" 176 | 177 | # Create image mount dir 178 | print_info "Create image mount point $rootfs" 179 | mkdir -p "${rootfs}" 180 | 181 | # Install dependencies 182 | for dep in binfmt-support qemu qemu-user-static debootstrap kpartx dmsetup dosfstools; do 183 | problem=$(dpkg -s $dep|grep installed) 184 | if [ "" == "$problem" ]; then 185 | print_info "No $dep. Setting up $dep" 186 | apt-get --force-yes --yes install "$dep" &>> "$LOG" 187 | fi 188 | done 189 | 190 | 191 | # Install raspbian key 192 | print_info "Fetching and installing rasbian public key from $RASBIAN_KEY_URL" 193 | wget --quiet "$RASBIAN_KEY_URL" -O - | apt-key add - &>> "$LOG" 194 | 195 | # Create image file 196 | print_info "Initializing image file $IMG" 197 | dd if=/dev/zero of=${IMG} bs=1MB count=$IMAGESIZE &>> "$LOG" 198 | 199 | print_info "Creating a loopback device for $IMG..." 200 | lodevice=$(losetup -f --show ${IMG}) 201 | print_info "Loopback $lodevice created." 202 | 203 | # Setup up /boot and /root partitions 204 | # TODO: fdisk always returns 1, so we have to temporary set +e 205 | set +e 206 | # TODO: find other way to verify partitions made (maybe fdisk | wc -l) 207 | print_info "Creating partitions on $IMG..." 208 | echo " 209 | n 210 | p 211 | 1 212 | 213 | +${BOOTSIZE} 214 | t 215 | c 216 | n 217 | p 218 | 2 219 | 220 | 221 | w 222 | " | fdisk ${lodevice} &>> "$LOG" 223 | set -e 224 | 225 | # Set up loopback devices 226 | print_info "Removing $lodevice ..." 227 | dmsetup remove_all &>> "$LOG" 228 | losetup -d ${lodevice} &>> "$LOG" 229 | 230 | print_info "Creating device map for $IMG ... " 231 | device=$(kpartx -va ${IMG} | sed -E 's/.*(loop[0-9])p.*/\1/g' | head -1) 232 | device="/dev/mapper/${device}" 233 | print_info "Device map created at $device" 234 | 235 | bootp="${device}p1" 236 | rootp="${device}p2" 237 | 238 | # Do bootp and rootp exist? 239 | sleep 5 240 | print_info "Checking if $bootp and $rootp exist..." 241 | [ ! -e "$bootp" ] && exit 1 242 | [ ! -e "$rootp" ] && exit 1 243 | 244 | # Create file systems 245 | print_info "Creating filesystems on $IMG ..." 246 | mkfs.vfat ${bootp} &>> "$LOG" 247 | mkfs.ext4 ${rootp} &>> "$LOG" 248 | 249 | print_info "Mounting $rootp to $rootfs ..." 250 | mount ${rootp} ${rootfs} &>> "$LOG" 251 | 252 | print_info "Creating directories in $rootfs ..." 253 | mkdir -p ${rootfs}/proc 254 | mkdir -p ${rootfs}/sys 255 | mkdir -p ${rootfs}/dev/pts 256 | mkdir -p ${rootfs}/usr/src/delivery 257 | 258 | # Mount pseudo file systems 259 | print_info "Mounting pseudo filesystems in $rootfs ..." 260 | mount -t proc proc ${rootfs}/proc 261 | mount -t sysfs sys ${rootfs}/sys 262 | mount --bind /dev ${rootfs}/dev 263 | mount --bind /dev/pts ${rootfs}/dev/pts 264 | 265 | # Mount our delivery path 266 | print_info "Mounting $DELIVERY_DIR in $rootfs ..." 267 | mount -o bind ${DELIVERY_DIR} ${rootfs}/usr/src/delivery 268 | 269 | print_info "Change working directory to ${rootfs} ..." 270 | cd "${rootfs}" 271 | 272 | # First stage of bootstrapping, from the outside 273 | print_info "Running debootstrap first stage" 274 | debootstrap --verbose --foreign --arch armhf --keyring \ 275 | /etc/apt/trusted.gpg ${DEB_RELEASE} ${rootfs} ${DEB_MIRROR} &>> $LOG 276 | 277 | # Second stage, using chroot and qemu-arm from the inside 278 | print_info "Copying $QEMU_ARM_STATIC into $rootfs" 279 | cp "$QEMU_ARM_STATIC" "${rootfs}/usr/bin/" &>> $LOG 280 | 281 | print_info "Running debootstrap second stage" 282 | LANG=C chroot "${rootfs}" /debootstrap/debootstrap --second-stage &>> $LOG 283 | 284 | print_info "Mounting $bootp to $bootfs ..." 285 | mount ${bootp} ${bootfs} &>> $LOG 286 | 287 | # Configure Debian release and mirror 288 | print_info "Configure apt in $rootfs..." 289 | echo "deb ${DEB_MIRROR} ${DEB_RELEASE} main contrib non-free 290 | deb http://apt.diybookscanner.org/raspbian wheezy main 291 | " > "${rootfs}/etc/apt/sources.list" 292 | 293 | # Configure Raspberry Pi boot options 294 | print_info "Writing $BOOT_CONF ..." 295 | echo " 296 | dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait 297 | " > /boot/cmdline.txt 298 | 299 | # Set up mount points 300 | print_info "Writing $rootfs/etc/fstab ..." 301 | echo " 302 | proc /proc proc defaults 0 0 303 | /dev/mmcblk0p1 /boot vfat defaults 0 2 304 | /dev/mmcblk0p2 / ext4 defaults,noatime 0 1 305 | tmpfs /tmp tmpfs defaults,noatime,nosuid,size=100m 0 0 306 | tmpfs /var/tmp tmpfs defaults,noatime,nosuid,size=30m 0 0 307 | tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=100m 0 0 308 | " > "$rootfs/etc/fstab" 309 | 310 | # Configure Hostname 311 | print_info "Writing $rootfs/etc/hostname ..." 312 | echo "spreadpi" > "$rootfs/etc/hostname" 313 | 314 | # Configure networking 315 | print_info "Writing $rootfs/etc/network/interfaces ..." 316 | echo "auto lo 317 | iface lo inet loopback 318 | 319 | auto eth0 320 | iface eth0 inet dhcp 321 | " > "$rootfs/etc/network/interfaces" 322 | 323 | # Configure loading of proprietary kernel modules 324 | print_info "Writing $rootfs/etc/modules ..." 325 | echo "vchiq 326 | snd_bcm2835 327 | " >> "$rootfs/etc/modules" 328 | 329 | print_info "Setting up keyboard layout..." 330 | echo "console-common console-data/keymap/policy select Select keymap from full list 331 | console-common console-data/keymap/full select us 332 | " > "$rootfs/debconf.set" 333 | 334 | # Run user-defined scripts from DELIVERY_DIR/scripts 335 | print_info "Running custom bootstrapping scripts" 336 | for path in $rootfs/usr/src/delivery/scripts/*; do 337 | script=$(basename "$path") 338 | print_info "- $script" 339 | DELIVERY_DIR=/usr/src/delivery LANG=C chroot ${rootfs} "/usr/src/delivery/scripts/$script" &>> $LOG 340 | done 341 | 342 | # Configure default mirror 343 | print_info "Writing $rootfs/apt/sources.list again, using non-local mirror..." 344 | echo "deb ${DEFAULT_DEB_MIRROR} ${DEB_RELEASE} main contrib non-free 345 | deb http://apt.diybookscanner.org/raspbian wheezy main 346 | " > "$rootfs/etc/apt/sources.list" 347 | 348 | # Clean up 349 | print_info "Cleaning up bootstrapped system" 350 | echo "#!/bin/bash 351 | aptitude update 352 | aptitude clean 353 | apt-get clean 354 | rm -f cleanup 355 | " > "$rootfs/cleanup" 356 | chmod +x "$rootfs/cleanup" 357 | LANG=C chroot ${rootfs} /cleanup &>> $LOG 358 | 359 | print_info "Change working directory to ${rootfs} ..." 360 | cd "${rootfs}" 361 | 362 | if $DEBUG; then 363 | print_info "Dropping into shell" 364 | LANG=C chroot ${rootfs} /bin/bash 365 | fi 366 | 367 | # Kill remaining qemu-arm-static processes 368 | if [ -n "$(pgrep qemu-arm-static)" ]; then 369 | print_info "Killing remaining qemu-arm-static processes..." 370 | kill -9 $(pgrep "qemu-arm-static") 371 | fi 372 | 373 | # Synchronize file systems 374 | print_info "sync filesystems, sleep 15 seconds" 375 | sync 376 | sleep 15 377 | 378 | cleanup -clean 379 | 380 | print_info "Successfully created image ${IMG}" 381 | trap - EXIT 382 | exit 0 383 | -------------------------------------------------------------------------------- /delivery/files/55-udisks.pkla: -------------------------------------------------------------------------------- 1 | [Storage Permissions] 2 | Identity=unix-group:plugdev 3 | Action=org.freedesktop.udisks.filesystem-mount;org.freedesktop.udisks.drive-eject;org.freedesktop.udisks.drive-detach;org.freedesktop.udisks.luks-unlock;org.freedesktop.udisks.inhibit-polling;org.freedesktop.udisks.drive-set-spindown 4 | ResultAny=yes 5 | ResultActive=yes 6 | ResultInactive=yes 7 | -------------------------------------------------------------------------------- /delivery/files/bashrc: -------------------------------------------------------------------------------- 1 | # ~/.bashrc: executed by bash(1) for non-login shells. 2 | # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) 3 | # for examples 4 | 5 | # If not running interactively, don't do anything 6 | [ -z "$PS1" ] && return 7 | 8 | # don't put duplicate lines or lines starting with space in the history. 9 | # See bash(1) for more options 10 | HISTCONTROL=ignoreboth 11 | 12 | # append to the history file, don't overwrite it 13 | shopt -s histappend 14 | 15 | # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) 16 | HISTSIZE=1000 17 | HISTFILESIZE=2000 18 | 19 | # check the window size after each command and, if necessary, 20 | # update the values of LINES and COLUMNS. 21 | shopt -s checkwinsize 22 | 23 | # If set, the pattern "**" used in a pathname expansion context will 24 | # match all files and zero or more directories and subdirectories. 25 | #shopt -s globstar 26 | 27 | # make less more friendly for non-text input files, see lesspipe(1) 28 | #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" 29 | 30 | # set variable identifying the chroot you work in (used in the prompt below) 31 | if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then 32 | debian_chroot=$(cat /etc/debian_chroot) 33 | fi 34 | 35 | # set a fancy prompt (non-color, unless we know we "want" color) 36 | case "$TERM" in 37 | xterm-color) color_prompt=yes;; 38 | esac 39 | 40 | # uncomment for a colored prompt, if the terminal has the capability; turned 41 | # off by default to not distract the user: the focus in a terminal window 42 | # should be on the output of commands, not on the prompt 43 | force_color_prompt=yes 44 | 45 | if [ -n "$force_color_prompt" ]; then 46 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then 47 | # We have color support; assume it's compliant with Ecma-48 48 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such 49 | # a case would tend to support setf rather than setaf.) 50 | color_prompt=yes 51 | else 52 | color_prompt= 53 | fi 54 | fi 55 | 56 | if [ "$color_prompt" = yes ]; then 57 | PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \$\[\033[00m\] ' 58 | else 59 | PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 60 | fi 61 | unset color_prompt force_color_prompt 62 | 63 | # If this is an xterm set the title to user@host:dir 64 | case "$TERM" in 65 | xterm*|rxvt*) 66 | PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" 67 | ;; 68 | *) 69 | ;; 70 | esac 71 | 72 | # enable color support of ls and also add handy aliases 73 | if [ -x /usr/bin/dircolors ]; then 74 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" 75 | alias ls='ls --color=auto' 76 | #alias dir='dir --color=auto' 77 | #alias vdir='vdir --color=auto' 78 | 79 | alias grep='grep --color=auto' 80 | alias fgrep='fgrep --color=auto' 81 | alias egrep='egrep --color=auto' 82 | fi 83 | 84 | # some more ls aliases 85 | #alias ll='ls -l' 86 | #alias la='ls -A' 87 | #alias l='ls -CF' 88 | 89 | # Alias definitions. 90 | # You may want to put all your additions into a separate file like 91 | # ~/.bash_aliases, instead of adding them here directly. 92 | # See /usr/share/doc/bash-doc/examples in the bash-doc package. 93 | 94 | if [ -f ~/.bash_aliases ]; then 95 | . ~/.bash_aliases 96 | fi 97 | 98 | # enable programmable completion features (you don't need to enable 99 | # this, if it's already enabled in /etc/bash.bashrc and /etc/profile 100 | # sources /etc/bash.bashrc). 101 | if [ -f /etc/bash_completion ] && ! shopt -oq posix; then 102 | . /etc/bash_completion 103 | fi 104 | -------------------------------------------------------------------------------- /delivery/files/config.yaml: -------------------------------------------------------------------------------- 1 | driver: chdkcamera 2 | plugins: 3 | - hidtrigger 4 | - web 5 | core: 6 | verbose: yes 7 | logfile: /home/spreads/.config/spreads/spreads.log 8 | capture_keys: [' ', b] 9 | loglevel: debug 10 | device: 11 | flip_target_pages: no 12 | parallel_capture: yes 13 | web: 14 | project_dir: /home/spreads/scans 15 | debug: no 16 | standalone_device: yes 17 | mode: scanner 18 | port: 5000 19 | -------------------------------------------------------------------------------- /delivery/files/spreadpi.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Perform SpreadPi initialization on first boot. 3 | 4 | [Service] 5 | Type=oneshot 6 | ExecStart=/usr/bin/spreadpi_init 7 | RemainAfterExit=yes 8 | 9 | [Install] 10 | WantedBy=multi-user.target 11 | -------------------------------------------------------------------------------- /delivery/files/spreadpi_init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | STATE_DIR=/var/lib/spreadpi 4 | mkdir -p $STATE_DIR 5 | 6 | if [ ! -f $STATE_DIR/overclock_set ]; then 7 | # We only want to overclock the older models 8 | if grep -Eq 'Revision\s*:\s*\w{4}[^4]\w' /proc/cpuinfo; then 9 | cat </boot/config.txt 10 | core_freq=500 11 | sdram_freq=600 12 | over_voltage=6 13 | arm_freq=1000 14 | EOM 15 | 16 | cat </etc/rc.local 17 | #!/bin/sh 18 | echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 19 | exit 0 20 | EOM 21 | fi 22 | touch $STATE_DIR/overclock_set 23 | fi 24 | 25 | if [ ! -f $STATE_DIR/part_resized ]; then 26 | # Return value will likely be error for fdisk as it fails to reload the 27 | # partition table because the root fs is mounted 28 | fdisk /dev/mmcblk0 < /etc/default/locale 7 | sed -i -e "s/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g" /etc/locale.gen 8 | locale-gen en_US.UTF-8 9 | -------------------------------------------------------------------------------- /delivery/scripts/02-firmware.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Install rpi-update and dependencies 5 | apt-get -y install --no-install-recommends git-core binutils ca-certificates curl 6 | wget --continue https://raw.github.com/Hexxeh/rpi-update/master/rpi-update -O /usr/bin/rpi-update 7 | chmod +x /usr/bin/rpi-update 8 | mkdir -p /lib/modules/3.1.9+ 9 | touch /boot/start.elf 10 | 11 | # Temporarily fake uname output to fix rpi-update 12 | mv /bin/uname /bin/uname.bak 13 | echo ' 14 | #\!/bin/sh 15 | echo "3.1.9+" 16 | ' > /bin/uname 17 | chmod +x /bin/uname 18 | 19 | # Update kernel and firmware 20 | rpi-update 21 | 22 | # Restore original uname 23 | mv /bin/uname.bak /bin/uname 24 | -------------------------------------------------------------------------------- /delivery/scripts/02-network.sh: -------------------------------------------------------------------------------- 1 | cat </etc/network/if-pre-up.d/iptables 2 | #!/bin/sh 3 | /sbin/iptables-restore < /etc/iptables.up.rules 4 | EOM 5 | 6 | chmod +x /etc/network/if-pre-up.d/iptables 7 | 8 | cat </etc/iptables.up.rules 9 | *nat 10 | :PREROUTING ACCEPT [1:60] 11 | :INPUT ACCEPT [1:60] 12 | :OUTPUT ACCEPT [3:300] 13 | :POSTROUTING ACCEPT [3:300] 14 | -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 5000 15 | COMMIT 16 | *filter 17 | :INPUT ACCEPT [290:21584] 18 | :FORWARD ACCEPT [0:0] 19 | :OUTPUT ACCEPT [200:20552] 20 | COMMIT 21 | EOM 22 | -------------------------------------------------------------------------------- /delivery/scripts/03-tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Install some basic tools and libraries 5 | apt-get -y install --no-install-recommends \ 6 | cifs-utils console-common htop less ntp openssh-server sudo vim \ 7 | systemd-sysv 8 | 9 | # User spreads should be able to shut the system down (used in web interface) 10 | echo 'spreads ALL=NOPASSWD: /sbin/shutdown' >> /etc/sudoers 11 | 12 | # Fix 'unable to resolve host spreadpi' errors 13 | sed -i -e 's/\(127.0.0.1.*\)/\1 spreadpi/g' /etc/hosts 14 | -------------------------------------------------------------------------------- /delivery/scripts/04-users.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Create root user 5 | echo "root:raspberry" | chpasswd 6 | cp "$DELIVERY_DIR/files/bashrc" /root/.bashrc 7 | 8 | 9 | # Create spreads user 10 | useradd -s /bin/bash -m spreads 11 | echo "spreads:spreads" |chpasswd 12 | cp "$DELIVERY_DIR/files/bashrc" /home/spreads/.bashrc 13 | mkdir -p /home/spreads/.ssh 14 | 15 | # Needed for mounting usb disks 16 | adduser spreads plugdev 17 | 18 | # Allow user to 'sudo' any command 19 | adduser spreads sudo 20 | 21 | if [ -e "$SSH_KEY" ]; then 22 | cp "$SSH_KEY" /home/spreads/.ssh/authorized_keys 23 | fi 24 | 25 | # Set permissions to spreads 26 | shopt -s dotglob 27 | cd /home/spreads && chown -R spreads:spreads * 28 | shopt -u dotglob 29 | -------------------------------------------------------------------------------- /delivery/scripts/05-udev.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Setup udev rules 5 | echo 'ACTION=="add", SUBSYSTEM=="usb", MODE:="666"' > /etc/udev/rules.d/99-usb.rules 6 | sed -i -e 's/KERNEL\!="eth\*|/KERNEL\!="/' /lib/udev/rules.d/75-persistent-net-generator.rules 7 | rm -f /etc/udev/rules.d/70-persistent-net.rules 8 | -------------------------------------------------------------------------------- /delivery/scripts/07-date.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | echo '#! /bin/bash 4 | if [ $(/bin/date +%Y) -lt 1971 ]; then /bin/date --set 2014-01-01; fi' > /etc/init.d/avoid1970 5 | 6 | chmod a+rx /etc/init.d/avoid1970 7 | update-rc.d avoid1970 defaults 8 | -------------------------------------------------------------------------------- /delivery/scripts/07-firstboot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | cp $DELIVERY_DIR/files/spreadpi_init /usr/bin/ 5 | chmod +x /usr/bin/spreadpi_init 6 | 7 | cp $DELIVERY_DIR/files/spreadpi.service /etc/systemd/system/ 8 | systemctl enable spreadpi 9 | -------------------------------------------------------------------------------- /delivery/scripts/08-udisks.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # User spreads needs to mount usb disks 4 | apt-get -y install dbus udisks 5 | cp $DELIVERY_DIR/files/55-udisks.pkla /etc/polkit-1/localauthority/50-local.d/ 6 | -------------------------------------------------------------------------------- /delivery/scripts/10-spreads.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Install spreads dependencies 5 | if [ -e $DELIVERY_DIR/spreads-sdist.tar.gz ]; then 6 | apt-get -y --force-yes install --no-install-recommends \ 7 | chdkptp python python-colorama python-yaml python-concurrent.futures \ 8 | python-blinker python-roman python-usb python-psutil \ 9 | python-hidapi-cffi python-isbnlib python-flask \ 10 | python-requests python-wand python-zipstream python-netifaces \ 11 | python-dbus liblua5.2-dev libusb-dev python-cffi libjpeg8-dev \ 12 | libturbojpeg1-dev 13 | apt-get -y install python-pip build-essential python2.7-dev pkg-config 14 | pip install tornado 15 | pip install jpegtran-cffi 16 | pip install lupa --install-option="--no-luajit" 17 | pip install chdkptp.py 18 | pip install $DELIVERY_DIR/spreads-sdist.tar.gz 19 | apt-get -y remove --purge --auto-remove build-essential 20 | else 21 | apt-get -y --force-yes install spreads spreads-web chdkptp 22 | fi 23 | 24 | # Create spreads configuration directoy 25 | mkdir -p /home/spreads/.config/spreads 26 | cp $DELIVERY_DIR/files/config.yaml /home/spreads/.config/spreads 27 | chown -R spreads /home/spreads/.config/spreads 28 | 29 | # Install spreads systemd service 30 | cp $DELIVERY_DIR/files/spreads.service /etc/systemd/system/ 31 | systemctl enable spreads 32 | --------------------------------------------------------------------------------