diff --git a/image/Jenkinsfile b/image/Jenkinsfile deleted file mode 100644 index 6785b86c2..000000000 --- a/image/Jenkinsfile +++ /dev/null @@ -1,61 +0,0 @@ -pipeline { - agent any - stages { - stage('Get image') { - environment { - RPI_DONWLOAD_URL = 'https://downloads.raspberrypi.org/raspbian_lite_latest' - RPI_ZIP_NAME = 'raspbian_lite_latest.zip' - RPI_IMAGE_NAME = '2017-11-29-raspbian-stretch-lite.img' - } - steps { - sh "$WORKSPACE/image/image-config.sh get_image $BUILD_DIRECTORY $RPI_ZIP_NAME $RPI_DONWLOAD_URL $RPI_IMAGE_NAME $IMAGE_NAME" - } - } - stage('Resize FS') { - environment { - SIZE = '7G' - } - steps { - sh '$WORKSPACE/image/image-config.sh resize_fs $SIZE $BUILD_DIRECTORY $IMAGE_NAME $DEV_ROOTFS' - } - } - stage('Configure interfaces') { - environment { - EXECUTE_FILE = 'iface.sh' - } - steps { - sh '$WORKSPACE/image/image-config.sh execute $BUILD_DIRECTORY/$IMAGE_NAME $PREFIX_PATH $DEV_ROOTFS $DEV_BOOT $WORKSPACE/image/$EXECUTE_FILE' - } - } - stage('Install Apps') { - environment { - EXECUTE_FILE = 'apps.sh' - } - steps { - sh '$WORKSPACE/image/image-config.sh execute $BUILD_DIRECTORY/$IMAGE_NAME $PREFIX_PATH $DEV_ROOTFS $DEV_BOOT $WORKSPACE/image/$EXECUTE_FILE' - } - } - stage('Install ROS') { - environment { - EXECUTE_FILE = 'ros.sh' - } - steps { - sh '$WORKSPACE/image/image-config.sh execute $BUILD_DIRECTORY/$IMAGE_NAME $PREFIX_PATH $DEV_ROOTFS $DEV_BOOT $WORKSPACE/image/$EXECUTE_FILE' - } - } - stage('Publish image') { - environment { - CONFIG_FILE = 'coex-ci.conf' - } - steps { - sh '$WORKSPACE/image/image-config.sh publish_image $BUILD_DIRECTORY $IMAGE_NAME $WORKSPACE $CONFIG_FILE $RELEASE_ID $RELEASE_BODY' - } - } - } - environment { - BUILD_DIRECTORY = '/home/pi/clever_builder/temp' - PREFIX_PATH = '/mnt' - DEV_BOOT = '/dev/disk/by-uuid/CDD4-B453' - DEV_ROOTFS = '/dev/disk/by-uuid/72bfc10d-73ec-4d9e-a54a-1cc507ee7ed2' - } -} diff --git a/image/Jenkinsfile-build b/image/Jenkinsfile-build deleted file mode 100644 index daa2180db..000000000 --- a/image/Jenkinsfile-build +++ /dev/null @@ -1,61 +0,0 @@ -pipeline { - agent any - parameters { - string(name: 'IMAGE_NAME', defaultValue: 'CLEVER-JENKINS-FILE.img', description: 'IMAGE_NAME') - //string(name: 'WORKSPACE', defaultValue: '', description: 'WORKSPACE') - } - environment { - BUILD_DIRECTORY = '/home/pi/temp' - PREFIX_PATH = '/mnt' - DEV_BOOT = '/dev/disk/by-uuid/CDD4-B453' - DEV_ROOTFS = '/dev/disk/by-uuid/72bfc10d-73ec-4d9e-a54a-1cc507ee7ed2' - - DEBIAN_FRONTEND = 'noninteractive' - LANG = 'C.UTF-8' - LC_ALL = 'C.UTF-8' - } - stages { - stage('Get image') { - environment { - RPI_DONWLOAD_URL = 'https://downloads.raspberrypi.org/raspbian_lite_latest' - RPI_ZIP_NAME = 'raspbian_lite_latest.zip' - RPI_IMAGE_NAME = '2017-11-29-raspbian-stretch-lite.img' - } - steps { - sh "$WORKSPACE/image/image-config.sh get_image $BUILD_DIRECTORY $RPI_ZIP_NAME $RPI_DONWLOAD_URL $RPI_IMAGE_NAME ${params.IMAGE_NAME}" - } - } - stage('Resize FS') { - environment { - SIZE = '7G' - } - steps { - sh "$WORKSPACE/image/image-config.sh resize_fs $SIZE $BUILD_DIRECTORY ${params.IMAGE_NAME} $DEV_ROOTFS" - } - } - stage('Configure interfaces') { - environment { - EXECUTE_FILE = 'iface.sh' - } - steps { - sh "$WORKSPACE/image/image-config.sh execute $BUILD_DIRECTORY/${params.IMAGE_NAME} $PREFIX_PATH $DEV_ROOTFS $DEV_BOOT $WORKSPACE/image/$EXECUTE_FILE" - } - } - stage('Install Apps') { - environment { - EXECUTE_FILE = 'apps.sh' - } - steps { - sh "$WORKSPACE/image/image-config.sh execute $BUILD_DIRECTORY/${params.IMAGE_NAME} $PREFIX_PATH $DEV_ROOTFS $DEV_BOOT $WORKSPACE/image/$EXECUTE_FILE" - } - } - stage('Install ROS') { - environment { - EXECUTE_FILE = 'ros.sh' - } - steps { - sh "$WORKSPACE/image/image-config.sh execute $BUILD_DIRECTORY/${params.IMAGE_NAME} $PREFIX_PATH $DEV_ROOTFS $DEV_BOOT $WORKSPACE/image/$EXECUTE_FILE" - } - } - } -} diff --git a/image/Jenkinsfile-release-new b/image/Jenkinsfile-release-new deleted file mode 100644 index cfb8c7334..000000000 --- a/image/Jenkinsfile-release-new +++ /dev/null @@ -1,56 +0,0 @@ -pipeline { - agent any - parameters { - string(name: 'IMAGE_NAME', defaultValue: '', description: 'IMAGE_NAME') - string(name: 'GWBT_RELEASE_ID', defaultValue: '', description: 'GWBT_RELEASE_ID') - string(name: 'GWBT_RELEASE_BODY', defaultValue: '', description: 'GWBT_RELEASE_BODY') - } - stages { - stage('Zip image') { - steps { - echo 'Zip image' - sh "zip $BUILD_DIRECTORY/$IMAGE_NAME.zip $BUILD_DIRECTORY/$IMAGE_NAME" - echo 'End of Zipping' - } - } - stage('Upload image') { - environment { - CONFIG_FILE = 'coex-ci.conf' - } - steps { - echo 'Upload image' - parameters { - string(name: 'IMAGE_LINK', defaultValue: '$($WORKSPACE/image/yadisk.py $BUILD_DIRECTORY/$CONFIG_FILE $BUILD_DIRECTORY/$IMAGE_NAME.zip)', description: 'IMAGE_NAME') - } - echo 'End of Upload' - } - } - stage('Send image to TESTER') { - steps { - echo 'Send image' - sh "# TODO" - echo 'End of Send image' - } - } - stage('Burn to MicroSD') { - steps { - echo 'Start Burn' - sh "# dd of=/dev/sda if=$BUILD_DIRECTORY/$IMAGE_NAME" - echo 'End of Burn' - } - } - stage('Publish image') { - environment { - CONFIG_FILE = 'coex-ci.conf' - } - steps { - echo 'Start Publish' - sh "$WORKSPACE/image/git_release.py $BUILD_DIRECTORY/$CONFIG_FILE ${params.GWBT_RELEASE_ID} ${params.GWBT_RELEASE_BODY} $IMAGE_NAME $IMAGE_LINK $(du -sh $BUILD_DIRECTORY/$IMAGE_NAME.zip | awk '{ print $1 }')" - echo 'End of Publish' - } - } - } - environment { - BUILD_DIRECTORY = '/home/pi/temp' - } -} diff --git a/image/apps.sh b/image/apps.sh deleted file mode 100755 index 3069a0ad8..000000000 --- a/image/apps.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/sh - -set -e - -################################################################################################################################## -# Установка необходимых программ -################################################################################################################################## - - -echo "\033[0;31m\033[1m$(date) | #1 apt update && apt upgrade\033[0m\033[0m" - -# install bootstrap tools -apt-get update -# && apt upgrade -y - - - -echo "\033[0;31m\033[1m$(date) | #2 Install programs\033[0m\033[0m" - -apt-get install --no-install-recommends -y \ - unzip \ - zip \ - ipython \ - screen \ - byobu \ - nmap \ - lsof \ - python-pip \ - git \ - isc-dhcp-server \ - tmux \ - vim \ - libpoco-dev \ - tcpdump - - - - - -echo "\033[0;31m\033[1m$(date) | #3 Write to /etc/wpa_supplicant/wpa_supplicant.conf\033[0m\033[0m" - -echo " -network={ - ssid=\"CLEVER\" - mode=2 - key_mgmt=WPA-PSK - psk=\"cleverwifi\" - frequency=2437 -}" >> /etc/wpa_supplicant/wpa_supplicant.conf - - - - - -echo "\033[0;31m\033[1m$(date) | #4 Write STATIC to /etc/dhcpcd.conf\033[0m\033[0m" - -echo " -interface wlan0 -static ip_address=192.168.11.1/24" >> /etc/dhcpcd.conf - - - - -echo "\033[0;31m\033[1m$(date) | #5 Write iface to /etc/default/isc-dhcp-server\033[0m\033[0m" - -# https://www.shellhacks.com/ru/sed-find-replace-string-in-file/ -sed -i 's/INTERFACESv4=\"\"/INTERFACESv4=\"wlan0\"/' /etc/default/isc-dhcp-server - - -echo "\033[0;31m\033[1m$(date) | #6 Write dhcp declaration subnet to /etc/dhcp/dhcpd.conf\033[0m\033[0m" - - -echo "subnet 192.168.11.0 netmask 255.255.255.0 { - range 192.168.11.11 192.168.11.254; - #option domain-name-servers 8.8.8.8; - #option domain-name "rpi.local"; - option routers 192.168.11.1; - option broadcast-address 192.168.11.255; - default-lease-time 600; - max-lease-time 7200; -}" >> /etc/dhcp/dhcpd.conf - - - -echo "\033[0;31m\033[1m$(date) | #7 Write start script for dhcpd to /etc/network/if-up.d/isc-dhcp-server\033[0m\033[0m" - -echo "#!/bin/sh -if [ \"\$IFACE\" = \"--all\" ]; -then sleep 10 && systemctl start isc-dhcp-server.service & -fi -" > /etc/network/if-up.d/isc-dhcp-server \ - && chmod +x /etc/network/if-up.d/isc-dhcp-server - - - -echo "\033[0;31m\033[1m$(date) | #8 Write magic script for rename SSID to /etc/rc.local\033[0m\033[0m" - -RENAME_SSID="sudo sed -i.OLD \"s/CLEVER/CLEVER-\$(head -c 100 /dev/urandom | xxd -ps -c 100 | sed -e 's/[^0-9]//g' | cut -c 1-4)/g\" /etc/wpa_supplicant/wpa_supplicant.conf && sudo sed -i '/sudo sed/d' /etc/rc.local && sudo reboot" - - -sed -i "19a$RENAME_SSID" /etc/rc.local - - -echo "\033[0;31m\033[1m$(date) | #9 Setup vim" - -echo "set mouse-=a -syntax on -" > /home/pi/.vimrc - - - -echo "\033[0;31m\033[1m$(date) | #9 End of install programs\033[0m\033[0m" - diff --git a/image/ros.sh b/image/ros.sh deleted file mode 100755 index cc7dd393e..000000000 --- a/image/ros.sh +++ /dev/null @@ -1,193 +0,0 @@ -#!/bin/sh - -set -e - -################################################################################################################################## -# ROS for user pi -################################################################################################################################## - -# ros http://wiki.ros.org/action/fullsearch/ROSberryPi/Installing%20ROS%20Kinetic%20on%20the%20Raspberry%20Pi -# maintainer @urpylka - -echo "\033[0;31m\033[1m$(date) | #0 Install ROS\033[0m\033[0m" - - - - -echo "\033[0;31m\033[1m$(date) | #1 Install dirmngr & add key to apt-key\033[0m\033[0m" - -# по умолчанию dirmngr отсуствует на образе и требуется для установки ключа -# http://wpblogger.su/tags/apt/ -apt-get install dirmngr -# setup keys -apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 - -# setup sources.list -echo "deb http://packages.ros.org/ros/ubuntu stretch main" > /etc/apt/sources.list.d/ros-latest.list - - - - -echo "\033[0;31m\033[1m$(date) | #2 apt update && apt upgrade\033[0m\033[0m" - -# install bootstrap tools -apt-get update -# && apt upgrade -y - - - - -echo "\033[0;31m\033[1m$(date) | #3 Install wget, unzip, python-rosdep, python-rosinstall-generator, python-wstool, python-rosinstall, build-essential, cmake\033[0m\033[0m" - -apt-get install --no-install-recommends -y \ - wget \ - unzip \ - python-rosdep \ - python-rosinstall-generator \ - python-wstool \ - python-rosinstall \ - build-essential \ - cmake \ - libjpeg8-dev - - - -echo "\033[0;31m\033[1m$(date) | #4 rosdep init && rosdep update\033[0m\033[0m" - -# bootstrap rosdep -rosdep init && rosdep update - - - - -echo "\033[0;31m\033[1m$(date) | #5 Prepare ros_comm packages to kinetic-ros_comm-wet.rosinstall\033[0m\033[0m" - -# create catkin workspace -mkdir -p /home/pi/ros_catkin_ws && cd /home/pi/ros_catkin_ws \ - && rosinstall_generator ros_comm --rosdistro kinetic --deps --wet-only --tar > kinetic-ros_comm-wet.rosinstall \ - && wstool init src kinetic-ros_comm-wet.rosinstall - - - -#echo "\033[0;31m\033[1m$(date) | #6 Install assimp-3.1.1 to /home/pi/ros_catkin_ws/external_src\033[0m\033[0m" - -# Unavailable Dependencies -#mkdir -p /home/pi/ros_catkin_ws/external_src \ -# && cd /home/pi/ros_catkin_ws/external_src \ -# && wget http://sourceforge.net/projects/assimp/files/assimp-3.1/assimp-3.1.1_no_test_models.zip/download -O assimp-3.1.1_no_test_models.zip \ -# && unzip assimp-3.1.1_no_test_models.zip \ -# && cd assimp-3.1.1 \ -# && cmake . -Wattributes \ -# && make \ -# && make install - - - - -echo "\033[0;31m\033[1m$(date) | #7 Prepare other ROS-packages to kinetic-custom_ros.rosinstall\033[0m\033[0m" - -cd /home/pi/ros_catkin_ws \ - && rosinstall_generator \ - actionlib actionlib_msgs angles async_web_server_cpp bond bond_core bondcpp bondpy camera_calibration_parsers camera_info_manager catkin class_loader cmake_modules cpp_common cv_bridge cv_camera diagnostic_msgs diagnostic_updater dynamic_reconfigure eigen_conversions gencpp geneus genlisp genmsg gennodejs genpy geographic_msgs geometry_msgs geometry2 image_transport libmavconn mavlink mavros_msgs message_filters message_generation message_runtime mk nav_msgs nodelet orocos_kdl pluginlib python_orocos_kdl ros ros_comm rosapi rosauth rosbag rosbag_migration_rule rosbag_storage rosbash rosboost_cfg rosbridge_library rosbridge_server rosbridge_suite rosbuild rosclean rosconsole rosconsole_bridge roscpp roscpp_serialization roscpp_traits roscreate rosgraph rosgraph_msgs roslang roslaunch roslib roslint roslisp roslz4 rosmake rosmaster rosmsg rosnode rosout rospack rosparam rospy rospy_tutorials rosserial rosserial_client rosserial_msgs rosserial_python rosservice rostest rostime rostopic rosunit roswtf sensor_msgs smclib std_msgs std_srvs stereo_msgs tf tf2 tf2_bullet tf2_eigen tf2_geometry_msgs tf2_kdl tf2_msgs tf2_py tf2_ros tf2_sensor_msgs tf2_tools topic_tools trajectory_msgs urdf urdf_parser_plugin usb_cam uuid_msgs visualization_msgs web_video_server xmlrpcpp mavros opencv3 mavros_extras \ - --rosdistro kinetic --deps --wet-only --tar > kinetic-custom_ros.rosinstall \ - && wstool merge -t src kinetic-custom_ros.rosinstall \ - && wstool update -t src - - - - -echo "\033[0;31m\033[1m$(date) | #8 Install dependencies apps with rosdep\033[0m\033[0m" - -# как я понял установка apt-get всяких зависимостей для ros-пакетов -# Resolving Dependencies with rosdep -cd /home/pi/ros_catkin_ws \ - && rosdep install -y --from-paths src --ignore-src --rosdistro kinetic -r --os=debian:stretch - - - - -echo "\033[0;31m\033[1m$(date) | #9 Refactor usb_cam in SRC\033[0m\033[0m" - -# добавление префикса с помощью двух define -# #define PIX_FMT_RGB24 AV_PIX_FMT_RGB24 -# #define PIX_FMT_YUV422P AV_PIX_FMT_YUV422P - -sed -i '/#define __STDC_CONSTANT_MACROS/a\#define PIX_FMT_RGB24 AV_PIX_FMT_RGB24\n#define PIX_FMT_YUV422P AV_PIX_FMT_YUV422P' /home/pi/ros_catkin_ws/src/usb_cam/src/usb_cam.cpp - - - -echo "\033[0;31m\033[1m$(date) | #10 Install GeographicLib datasets\033[0m\033[0m" - -/home/pi/ros_catkin_ws/src/mavros/mavros/scripts/install_geographiclib_datasets.sh - - - - -echo "\033[0;31m\033[1m$(date) | #11 Build light packages on 2 threads\033[0m\033[0m" - -# Building the catkin Workspace -cd /home/pi/ros_catkin_ws && ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic -j2 --pkg actionlib actionlib_msgs angles async_web_server_cpp bond bond_core bondcpp bondpy camera_calibration_parsers camera_info_manager catkin class_loader cmake_modules cpp_common diagnostic_msgs diagnostic_updater dynamic_reconfigure eigen_conversions gencpp geneus genlisp genmsg gennodejs genpy geographic_msgs geometry_msgs geometry2 image_transport libmavconn mavlink mavros_msgs message_filters message_generation message_runtime mk nav_msgs nodelet orocos_kdl pluginlib python_orocos_kdl ros ros_comm rosapi rosauth rosbag rosbag_migration_rule rosbag_storage rosbash rosboost_cfg rosbridge_library rosbridge_server rosbridge_suite rosbuild rosclean rosconsole rosconsole_bridge roscpp roscpp_serialization roscpp_traits roscreate rosgraph rosgraph_msgs roslang roslaunch roslib roslint roslisp roslz4 rosmake rosmaster rosmsg rosnode rosout rospack rosparam rospy rospy_tutorials rosserial rosserial_client rosserial_msgs rosserial_python rosservice rostest rostime rostopic rosunit roswtf sensor_msgs smclib std_msgs std_srvs stereo_msgs tf tf2 tf2_bullet tf2_eigen tf2_geometry_msgs tf2_kdl tf2_msgs tf2_py tf2_ros tf2_sensor_msgs tf2_tools topic_tools trajectory_msgs urdf urdf_parser_plugin usb_cam uuid_msgs visualization_msgs xmlrpcpp - - - - -echo "\033[0;31m\033[1m$(date) | #12 Build heavy packages\033[0m\033[0m" - -# Building the catkin Workspace -cd /home/pi/ros_catkin_ws && ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic -j1 --pkg mavros opencv3 cv_bridge cv_camera mavros_extras web_video_server - - - -echo "\033[0;31m\033[1m$(date) | #13 Create catkin_ws\033[0m\033[0m" - -mkdir -p /home/pi/catkin_ws/src \ - && cd /home/pi/catkin_ws \ - && . /opt/ros/kinetic/setup.sh \ - && catkin init \ - && wstool init /home/pi/catkin_ws/src - - - - -echo "\033[0;31m\033[1m$(date) | #14 Install CLEVER-BUNDLE\033[0m\033[0m" - -cd /home/pi/catkin_ws/src \ - && git clone https://github.com/CopterExpress/clever.git clever \ - && pip install wheel \ - && pip install -r /home/pi/catkin_ws/src/clever/clever/requirements.txt \ - && cd /home/pi/catkin_ws \ - && . /opt/ros/kinetic/setup.sh \ - && catkin_make -j1 \ - && systemctl enable /home/pi/catkin_ws/src/clever/deploy/roscore.service \ - && systemctl enable /home/pi/catkin_ws/src/clever/deploy/clever.service - - - -echo "\033[0;31m\033[1m$(date) | #15 Add mjpg-streamer at /home/pi\033[0m\033[0m" - -# https://github.com/jacksonliam/mjpg-streamer - -cd /home/pi \ - && git clone https://github.com/jacksonliam/mjpg-streamer.git \ - && cd /home/pi/mjpg-streamer/mjpg-streamer-experimental \ - && make \ - && make install - - - -echo "\033[0;31m\033[1m$(date) | #16 Add ENV vars\033[0m\033[0m" - -# setup environment -echo "LANG=C.UTF-8" >> /home/pi/.bashrc -echo "LC_ALL=C.UTF-8" >> /home/pi/.bashrc -echo "ROS_DISTRO=kinetic" >> /home/pi/.bashrc -echo "export ROS_IP=192.168.11.1" >> /home/pi/.bashrc - -echo "source /opt/ros/kinetic/setup.bash" >> /home/pi/.bashrc \ - && echo "source /home/pi/catkin_ws/devel/setup.bash" >> /home/pi/.bashrc - -chown -Rf pi:pi /home/pi - - - -echo "\033[0;31m\033[1m$(date) | #17 END of ROS INSTALLATION\033[0m\033[0m" diff --git a/image/git_release.py b/image_builder/git_release.py similarity index 89% rename from image/git_release.py rename to image_builder/git_release.py index e434aba57..096eabaab 100755 --- a/image/git_release.py +++ b/image_builder/git_release.py @@ -2,7 +2,7 @@ # # Simple github release body-editor -# Smirnov Artem @urpylka +# @urpylka Artem Smirnov # # Use: # python git_release.py CONFIG_FILE RELEASE_ID RELEASE_BODY @@ -13,7 +13,8 @@ import requests, sys, urllib def json_wrapper(image_name, image_link, image_size, old_text): - old_text = urllib.unquote_plus(old_text) + # Don't need for Jenkins plugin + #old_text = urllib.unquote_plus(old_text) buffer = "### Download\n* [" + image_name + ".zip](" + image_link + ") (" + image_size + ")\n\n" + old_text js = {} js["body"] = buffer diff --git a/image/image-config.sh b/image_builder/image_config.sh similarity index 52% rename from image/image-config.sh rename to image_builder/image_config.sh index 500282d55..641bb331b 100755 --- a/image/image-config.sh +++ b/image_builder/image_config.sh @@ -1,51 +1,42 @@ -#!/bin/sh +#!/bin/bash +# Exit immidiately on non-zero result set -e # # Script for image configure -# @smirart Smirnov Artem +# @urpylka Artem Smirnov +# @dvornikov-aa Andrey Dvornikov # - -# PREFIX_PATH=/mnt -# IMAGE=/home/pi/2017-11-29-raspbian-stretch-lite.img -# -# # blkid -# UUID_BOOT=CDD4-B453 -# UUID_ROOTFS=72bfc10d-73ec-4d9e-a54a-1cc507ee7ed2 -# -# # /dev/disk/by-label/boot -# DEV_BOOT=/dev/disk/by-uuid/$UUID_BOOT -# # /dev/disk/by-label$2 -# DEV_ROOTFS=/dev/disk/by-uuid/$UUID_ROOTFS - - get_image() { -# STATIC -# TEMPLATE: get_image $BUILD_DIRECTORY $RPI_ZIP_NAME $RPI_DONWLOAD_URL $RPI_IMAGE_NAME $IMAGE_NAME - - echo 'Download RaspbianOS' - echo "$(date) | 1. Download raspbian lite" - if [ ! -e "$1/$2" ]; - then wget -nv -O $1/$2 $3 - fi - echo "$(date) | Downloading complete" - echo 'Unzip image' - echo "$(date) | 2. Unzip raspbian lite" - if [ ! -e "$1/$4" ]; - then unzip -uo $1/$2 -d $1 +# STATIC FUNCTION +# TEMPLATE: get_image $BUILD_DIR $RPI_DONWLOAD_URL $IMAGE_NAME + + local RPI_ZIP_NAME=$(basename $2) + if [ ! -e "$1/$RPI_ZIP_NAME" ]; + then + echo "$(date) | 1. Downloading original Linux distribution" + wget -nv -O $1/$RPI_ZIP_NAME $2 + echo "$(date) | Downloading complete" + else + echo "$(date) | 1. Linux distribution already donwloaded" fi - echo "$(date) | Unziping complete" - echo 'Duplicate image' - cp -f $1/$4 $1/$5 + echo "$(date) | 2. Unzipping Linux distribution image" + local RPI_IMAGE_NAME=$(echo $RPI_ZIP_NAME | sed 's/zip/img/') + unzip -p $1/$RPI_ZIP_NAME $RPI_IMAGE_NAME > $1/$IMAGE_NAME + echo "$(date) | Unzipping complete" } resize_fs() { - # STATIC - # TEMPLATE: resize_fs $SIZE $BUILD_DIRECTORY $IMAGE_NAME $DEV_ROOTFS + # STATIC FUNCTION + # TEMPLATE: resize_fs $SIZE $BUILD_DIR $IMAGE_NAME + + # Partitions numbers + local BOOT_PARTITION=1 + local ROOT_PARTITION=2 set +e @@ -63,53 +54,65 @@ resize_fs() { # ", +" : расширяет раздел до размеров образа # -N 2 : выбирает раздел 2 для работы - echo "\033[0;31m\033[1mTruncate image\033[0m\033[0m" \ + # There is a risk that sfdisk will ask for a disk remount to update partition table + # TODO: Check sfdisk exit code + + echo -e "\033[0;31m\033[1mTruncate image\033[0m\033[0m" \ && truncate -s$1 $2/$3 \ && echo "Mount loop-image: $2/$3" \ && local DEV_IMAGE=$(losetup -Pf $2/$3 --show) \ && sleep 0.5 \ - && echo "\033[0;31m\033[1mMount loop-image: $1\033[0m\033[0m" \ + && echo -e "\033[0;31m\033[1mMount loop-image: $1\033[0m\033[0m" \ && echo ", +" | sfdisk -N 2 $DEV_IMAGE \ && sleep 0.5 \ - && echo "\033[0;31m\033[1mCheck & repair filesystem after expand partition\033[0m\033[0m" \ - && e2fsck -fvy $4 \ - && echo "\033[0;31m\033[1mExpand filesystem\033[0m\033[0m" \ - && resize2fs $4 \ - && echo "\033[0;31m\033[1mUmount loop-image\033[0m\033[0m" \ + && losetup -d $DEV_IMAGE \ + && sleep 0.5 \ + && local DEV_IMAGE=$(losetup -Pf $2/$3 --show) \ + && sleep 0.5 \ + && echo -e "\033[0;31m\033[1mCheck & repair filesystem after expand partition\033[0m\033[0m" \ + && e2fsck -fvy "${DEV_IMAGE}p${ROOT_PARTITION}" \ + && echo -e "\033[0;31m\033[1mExpand filesystem\033[0m\033[0m" \ + && resize2fs "${DEV_IMAGE}p${ROOT_PARTITION}" \ + && echo -e "\033[0;31m\033[1mUmount loop-image\033[0m\033[0m" \ && losetup -d $DEV_IMAGE set -e } -publish_image() { +publish_image_python() { -# STATIC -# TEMPLATE: publish_image $BUILD_DIRECTORY $IMAGE_NAME $WORKSPACE $CONFIG_FILE $RELEASE_ID $RELEASE_BODY +# STATIC FUNCTION +# TEMPLATE: publish_image_python $BUILD_DIR $IMAGE_NAME $WORKSPACE $CONFIG_FILE $RELEASE_ID $RELEASE_BODY # https://developer.github.com/v3/repos/releases/ #RELEASE_BODY="### Changelog\n* Add /boot/cmdline.txt net.ifnames=0 https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/\n* Updated cophelper\n* Installed copstat" echo 'Zip image' \ - && zip $1/$2.zip $1/$2 \ - && echo 'Upload image' \ - && local IMAGE_LINK=$($3/image/yadisk.py $1/$4 $1/$2.zip) \ + && if [ ! -e "$1/$2.zip" ]; + then zip $1/$2.zip $1/$2 + fi + echo 'Upload image' \ + && local IMAGE_LINK=$($3/image_builder/yadisk.py $1/$4 $1/$2.zip) \ && local IMAGE_SIZE=$(du -sh $1/$2.zip | awk '{ print $1 }') \ && echo "Make downloads in GH-release" \ - && $3/image/git_release.py $1/$4 $5 $6 $2 $IMAGE_LINK $IMAGE_SIZE + && $3/image_builder/git_release.py $1/$4 $5 $6 $2 $IMAGE_LINK $IMAGE_SIZE +# echo "Fake publish" } -publish_image2() { +publish_image_bash() { -# STATIC -# TEMPLATE: publish_image $BUILD_DIRECTORY $IMAGE_NAME $WORKSPACE $CONFIG_FILE $RELEASE_ID $RELEASE_BODY +# STATIC FUNCTION +# TEMPLATE: publish_image_bash $BUILD_DIR $IMAGE_NAME $WORKSPACE $CONFIG_FILE $RELEASE_ID $RELEASE_BODY # https://developer.github.com/v3/repos/releases/ #RELEASE_BODY="### Changelog\n* Add /boot/cmdline.txt net.ifnames=0 https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/\n* Updated cophelper\n* Installed copstat" echo 'Zip image' \ - && zip $1/$2.zip $1/$2 \ - && echo 'Upload image' \ - && local IMAGE_LINK=$($3/image/yadisk.py $1/$4 $1/$2.zip) \ + && if [ ! -e "$1/$2.zip" ]; + then zip $1/$2.zip $1/$2 + fi + echo 'Upload image' \ + && local IMAGE_LINK=$($3/image_builder/yadisk.py $1/$4 $1/$2.zip) \ && local IMAGE_SIZE=$(du -sh $1/$2.zip | awk '{ print $1 }') \ && local NEW_RELEASE_BODY="### Download\n* [$2.zip]($IMAGE_LINK) ($IMAGE_SIZE)\n\n$6" \ && local DATA="{ \"body\":\"$NEW_RELEASE_BODY\" }" \ @@ -118,17 +121,17 @@ publish_image2() { burn_image() { -# STATIC +# STATIC FUNCTION # TEMPLATE: burn_image $IMAGE_PATH $MICROSD_DEV - echo "\033[0;31m\033[1mBurn image\033[0m\033[0m" \ + echo -e "\033[0;31m\033[1mBurn image\033[0m\033[0m" \ && dd if=$1 of=$2 \ - && echo "\033[0;31m\033[1mBurn image finished!\033[0m\033[0m" + && echo -e "\033[0;31m\033[1mBurn image finished!\033[0m\033[0m" } burn_and_reboot() { -# STATIC +# STATIC FUNCTION # TEMPLATE: burn_and_reboot $IMAGE_PATH $MICROSD_DEV burn_image $1 $2 \ @@ -137,8 +140,12 @@ burn_and_reboot() { mount_system() { - # STATIC - # TEMPLATE: mount_system $IMAGE $PREFIX_PATH $DEV_ROOTFS $DEV_BOOT + # STATIC FUNCTION + # TEMPLATE: mount_system $IMAGE $MOUNT_POINT + + # Partitions numbers + local BOOT_PARTITION=1 + local ROOT_PARTITION=2 # https://www.stableit.ru/2011/05/losetup.html # -f : losetup выбирает незанятое имя устройства, например /dev/loop2 @@ -146,40 +153,41 @@ mount_system() { # например /dev/loop0p1 и /dev/loop0p2 # --show : печатает имя устройства, например /dev/loop4 - echo "\033[0;31m\033[1mMount loop-image: $1\033[0m\033[0m" - DEV_IMAGE=$(losetup -Pf $1 --show) + echo -e "\033[0;31m\033[1mMount loop-image: $1\033[0m\033[0m" + local DEV_IMAGE=$(losetup -Pf $1 --show) sleep 0.5 - echo "\033[0;31m\033[1mMount dirs $2 & $2/boot\033[0m\033[0m" - mount $3 $2 - mount $4 $2/boot + echo -e "\033[0;31m\033[1mMount dirs $2 & $2/boot\033[0m\033[0m" + #mount $3 $2 + #mount $4 $2/boot + mount "${DEV_IMAGE}p${ROOT_PARTITION}" $2 + mount "${DEV_IMAGE}p${BOOT_PARTITION}" $2/boot - echo "\033[0;31m\033[1mBind system dirs\033[0m\033[0m" + echo -e "\033[0;31m\033[1mBind system dirs\033[0m\033[0m" # https://github.com/debian-pi/raspbian-ua-netinst/issues/314 echo "Mounting /proc in chroot... " if [ ! -d $2/proc ] ; then - mkdir -p $2/proc - echo "Created $2/proc" + mkdir -p $2/proc \ + && echo "Created $2/proc" fi - mount -t proc -o nosuid,noexec,nodev proc $2/proc - echo "OK" + mount -t proc -o nosuid,noexec,nodev proc $2/proc \ + && echo "OK" echo "Mounting /sys in chroot... " if [ ! -d $2/sys ] ; then - mkdir -p $2/sys - echo "Created $2/sys" + mkdir -p $2/sys \ + && echo "Created $2/sys" fi - mount -t sysfs -o nosuid,noexec,nodev sysfs $2/sys - echo "OK" + mount -t sysfs -o nosuid,noexec,nodev sysfs $2/sys \ + && echo "OK" - echo "Mounting /dev/ and /dev/pts in chroot... " - mkdir -p -m 755 $2/dev/pts - mount -t devtmpfs -o mode=0755,nosuid devtmpfs $2/dev - mount -t devpts -o gid=5,mode=620 devpts $2/dev/pts + echo "Mounting /dev/ and /dev/pts in chroot... " \ + && mkdir -p -m 755 $2/dev/pts \ + && mount -t devtmpfs -o mode=0755,nosuid devtmpfs $2/dev \ + && mount -t devpts -o gid=5,mode=620 devpts $2/dev/pts \ + && echo "OK" # mount -t devpts none "$2/dev/pts" -o ptmxmode=0666,newinstance # ln -fs "pts/ptmx" "$2/dev/ptmx" - echo "OK" - # mount -o bind /dev $2/dev # mount -t proc proc $2/proc @@ -189,8 +197,8 @@ mount_system() { # mount -t sysfs sys $2/sys # mount --bind /dev $2/dev - echo "\033[0;31m\033[1mCopy DNS records\033[0m\033[0m" - cp -L /etc/resolv.conf $2/etc/resolv.conf + echo -e "\033[0;31m\033[1mCopy DNS records\033[0m\033[0m" \ + && cp -L /etc/resolv.conf $2/etc/resolv.conf # https://wiki.archlinux.org/index.php/Change_root_(%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9) # http://www.unix-lab.org/posts/chroot/ @@ -198,73 +206,106 @@ mount_system() { # https://losst.ru/vosstanovlenie-grub2 # http://unixteam.ru/content/virtualizaciya-ili-zapuskaem-prilozhenie-v-chroot-okruzhenii-razmyshleniya # http://help.ubuntu.ru/wiki/%D0%B2%D0%BE%D1%81%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5_grub - echo "\033[0;31m\033[1mEnter chroot\033[0m\033[0m" - chroot $2 /bin/bash + echo -e "\033[0;31m\033[1mEnter chroot\033[0m\033[0m" \ + && chroot $2 /bin/bash + + umount_system $2 $DEV_IMAGE } -mount_system2() { +execute() { - # STATIC - # TEMPLATE: mount_system2 $IMAGE $PREFIX_PATH $DEV_ROOTFS $DEV_BOOT $EXECUTE_FILE + # STATIC FUNCTION + # TEMPLATE: execute $IMAGE $MOUNT_POINT $EXECUTE_FILE ... - echo "\033[0;31m\033[1mMount loop-image: $1\033[0m\033[0m" - DEV_IMAGE=$(losetup -Pf $1 --show) + # Partitions numbers + local BOOT_PARTITION=1 + local ROOT_PARTITION=2 + + echo -e "\033[0;31m\033[1mMount loop-image: $1\033[0m\033[0m" + local DEV_IMAGE=$(losetup -Pf $1 --show) sleep 0.5 - echo "\033[0;31m\033[1mMount dirs $2 & $2/boot\033[0m\033[0m" - mount $3 $2 - mount $4 $2/boot + echo -e "\033[0;31m\033[1mMount dirs $2 & $2/boot\033[0m\033[0m" + mount "${DEV_IMAGE}p${ROOT_PARTITION}" $2 + mount "${DEV_IMAGE}p${BOOT_PARTITION}" $2/boot - echo "\033[0;31m\033[1mBind system dirs\033[0m\033[0m" + echo -e "\033[0;31m\033[1mBind system dirs\033[0m\033[0m" echo "Mounting /proc in chroot... " if [ ! -d $2/proc ] ; then - mkdir -p $2/proc - echo "Created $2/proc" + mkdir -p $2/proc + echo "Created $2/proc" fi - mount -t proc -o nosuid,noexec,nodev proc $2/proc - echo "OK" - + mount -t proc -o nosuid,noexec,nodev proc $2/proc \ + && echo "OK" + echo "Mounting /sys in chroot... " if [ ! -d $2/sys ] ; then - mkdir -p $2/sys - echo "Created $2/sys" + mkdir -p $2/sys + echo "Created $2/sys" fi - mount -t sysfs -o nosuid,noexec,nodev sysfs $2/sys - echo "OK" - - echo "Mounting /dev/ and /dev/pts in chroot... " - mkdir -p -m 755 $2/dev/pts - mount -t devtmpfs -o mode=0755,nosuid devtmpfs $2/dev - mount -t devpts -o gid=5,mode=620 devpts $2/dev/pts - echo "OK" - - echo "\033[0;31m\033[1mCopy DNS records\033[0m\033[0m" - cp -L /etc/resolv.conf $2/etc/resolv.conf - - echo "\033[0;31m\033[1m$(date) | Enter chroot\033[0m\033[0m" - chroot $2 /bin/sh -c "$5" + mount -t sysfs -o nosuid,noexec,nodev sysfs $2/sys \ + && echo "OK" + + echo "Mounting /dev/ and /dev/pts in chroot... " \ + && mkdir -p -m 755 $2/dev/pts \ + && mount -t devtmpfs -o mode=0755,nosuid devtmpfs $2/dev \ + && mount -t devpts -o gid=5,mode=620 devpts $2/dev/pts \ + && echo "OK" + + echo -e "\033[0;31m\033[1mCopy DNS records\033[0m\033[0m" \ + && cp -L /etc/resolv.conf $2/etc/resolv.conf + + echo -e "\033[0;31m\033[1m$(date) | Enter chroot\033[0m\033[0m" + script_name=$(basename $3) + script_path_root="$2/root/$script_name" + # Copy script into chroot fs + # TODO: Find more suitable location for temporary script storage + cp "$3" "$script_path_root" + # Its important to save arguments (direct ${@:4} causes problems) + script_args="${@:4}" + # Run script in chroot with additional arguments + chroot $2 /bin/sh -c "/root/$script_name $script_args" + # Removing script from chroot fs + rm "$script_path_root" + + umount_system $2 $DEV_IMAGE } umount_system() { - # STATIC - # TEMPLATE: umount_system $PREFIX_PATH - - echo "\033[0;31m\033[1m$(date) | Umount recursive dirs: $1\033[0m\033[0m" - umount -fR $1 - echo "\033[0;31m\033[1m$(date) | Umount loop-image\033[0m\033[0m" - losetup -d $DEV_IMAGE -} - -umount_system2() { + # STATIC FUNCTION + # TEMPLATE: umount_system $MOUNT_POINT $DEV_IMAGE - # STATIC - # TEMPLATE: umount_system $PREFIX_PATH - - echo "\033[0;31m\033[1m$(date) | Umount recursive dirs: $1\033[0m\033[0m" - umount -fR $1 - echo "\033[0;31m\033[1m$(date) | Umount loop-image\033[0m\033[0m" - losetup -D + echo -e "\033[0;31m\033[1m$(date) | Umount recursive dirs: $1\033[0m\033[0m" + # There is a risk that umount will fail + set +e + # Successfull unmount flag (false at thismoment) + umount_ok=false + # Repeat 5 times + for i in {1..5} + do + # Unmount chroot rootfs and boot partition + umount -fR $1 + # If no problems detected + if [[ $? == 0 ]] + then + echo -e "\033[0;31m\033[1m$(date) | Successfull unmount\033[0m\033[0m" + # Set flag + umount_ok=true + # Exit loop + break + fi + # Unmount has failed + echo -e "\033[0;31m\033[1m$(date) | Unmount failed\033[0m\033[0m" + # Wait for some time + sleep 2 + done + set -e + # Jenkins job will fail if this condition is not true + [[ "$umount_ok" == true ]] + echo -e "\033[0;31m\033[1m$(date) | Umount loop-image\033[0m\033[0m" + #losetup -d $DEV_IMAGE + losetup -d $2 } set_config_var() { @@ -291,20 +332,23 @@ EOF configure_system() { - # STATIC - # TEMPLATE: configure_system $IMAGE $PREFIX_PATH $DEV_ROOTFS $DEV_BOOT + # TEMPLATE: configure_system $IMAGE $MOUNT_POINT $ROOT_PARTITON $BOOT_PARTITION local BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf local CONFIG=/boot/config.txt + # Partitions numbers + local BOOT_PARTITION=1 + local ROOT_PARTITION=2 + BLACKLIST=$2$BLACKLIST CONFIG=$2$CONFIG # 1. Примонитровать образ # https://raspberrypi.stackexchange.com/questions/13137/how-can-i-mount-a-raspberry-pi-linux-distro-image - # mount -v -o offset=48234496 -t ext4 2017-11-29-raspbian-stretch-lite.img $PREFIX_PATH - # mount -v -o offset=4194304,sizelimit=29360128 -t vfat 2017-11-29-raspbian-stretch-lite.img $PREFIX_PATH/boot + # mount -v -o offset=48234496 -t ext4 2017-11-29-raspbian-stretch-lite.img $MOUNT_POINT + # mount -v -o offset=4194304,sizelimit=29360128 -t vfat 2017-11-29-raspbian-stretch-lite.img $MOUNT_POINT/boot # # fdisk -l 2017-11-29-raspbian-stretch-lite.img # https://www.stableit.ru/2011/05/losetup.html @@ -312,25 +356,25 @@ configure_system() { # -P : losetup монтирует разделы в образе как отдельные подразделы, # например /dev/loop0p1 и /dev/loop0p2 # --show : печатает имя устройства, например /dev/loop4 - echo "\033[0;31m\033[1mMount loop-image: $1\033[0m\033[0m" + echo -e "\033[0;31m\033[1mMount loop-image: $1\033[0m\033[0m" DEV_IMAGE=$(losetup -Pf $1 --show) sleep 0.5 - echo "\033[0;31m\033[1mMount dirs $2 & $2/boot\033[0m\033[0m" - mount $3 $2 - mount $4 $2/boot + echo -e "\033[0;31m\033[1mMount dirs $2 & $2/boot\033[0m\033[0m" + mount ${DEV_IMAGE}p${ROOT_PARTITION} $2 + mount ${DEV_IMAGE}p${BOOT_PARTITION} $2/boot # 2. Изменить необходимые настройки # 2.1. Включить sshd - echo "\033[0;31m\033[1mTurn on sshd\033[0m\033[0m" + echo -e "\033[0;31m\033[1mTurn on sshd\033[0m\033[0m" touch $2/boot/ssh # 2.2. Включить GPIO # Включено по умолчанию # 2.3. Включить I2C - echo "\033[0;31m\033[1mTurn on I2C\033[0m\033[0m" + echo -e "\033[0;31m\033[1mTurn on I2C\033[0m\033[0m" set_config_var dtparam=i2c_arm on $CONFIG && if ! [ -e $BLACKLIST ]; then @@ -343,7 +387,7 @@ configure_system() { fi # 2.4. Включить SPI - echo "\033[0;31m\033[1mTurn on SPI\033[0m\033[0m" + echo -e "\033[0;31m\033[1mTurn on SPI\033[0m\033[0m" set_config_var dtparam=spi on $CONFIG && if ! [ -e $BLACKLIST ]; then @@ -359,13 +403,13 @@ configure_system() { # 2.8. Настроить DHCPd на wlan # Отмонтировать образ - umount_system $2 + umount_system $2 $DEV_IMAGE } prepare_fs() { - # STATIC + # STATIC FUNCTION # TEMPLATE: prepare_fs $IMAGE $SIZE date @@ -381,11 +425,11 @@ prepare_fs() { install_docker() { - # STATIC - # TEMPLATE: install_docker $IMAGE $PREFIX_PATH $DEV_ROOTFS $DEV_BOOT + # STATIC FUNCTION + # TEMPLATE: install_docker $IMAGE $MOUNT_POINT $DEV_ROOTFS $DEV_BOOT # https://askubuntu.com/questions/485567/unexpected-end-of-file - mount_system $1 $2 $3 $4 << EOF + mount_system $1 $2 << EOF #!/bin/bash # https://www.raspberrypi.org/blog/docker-comes-to-raspberry-pi/ curl -sSL https://get.docker.com | sh @@ -395,15 +439,14 @@ service docker start docker pull smirart/rpi-ros:sshd docker run -di --restart unless-stopped -p 192.168.0.121:2202:22 -t smirart/rpi-ros:sshd EOF - umount_system $2 } test_docker() { - # STATIC - # TEMPLATE: test_docker $IMAGE $PREFIX_PATH $DEV_ROOTFS $DEV_BOOT + # STATIC FUNCTION + # TEMPLATE: test_docker $IMAGE $MOUNT_POINT - mount_system $1 $2 $3 $4 << EOF + mount_system $1 $2 << EOF #!/bin/bash # https://www.raspberrypi.org/blog/docker-comes-to-raspberry-pi/ service docker start @@ -411,28 +454,8 @@ sleep 1 docker images docker ps -a EOF - umount_system $2 } -enter() { - - # STATIC - # TEMPLATE: enter $IMAGE $PREFIX_PATH $DEV_ROOTFS $DEV_BOOT - - mount_system $1 $2 $3 $4 - umount_system $2 -} - -execute() { - - # STATIC - # TEMPLATE: execute $IMAGE $PREFIX_PATH $DEV_ROOTFS $DEV_BOOT $EXECUTE_FILE - - mount_system2 $1 $2 $3 $4 "$(cat $5)" - umount_system2 $2 -} - - # очистить history # https://askubuntu.com/questions/191999/how-to-clear-bash-history-completely # cat /dev/null > ~/.bash_history && history -c && exit @@ -455,7 +478,6 @@ then echo "" \ && exit 1 fi - echo "\$#: $#" echo "\$1: $1" echo "\$2: $2" @@ -472,24 +494,24 @@ echo "\$7: $7" # configure_system case "$1" in - enter) # enter $IMAGE $PREFIX_PATH $DEV_ROOTFS $DEV_BOOT - enter $2 $3 $4 $5;; + mount_system) # mount_system $IMAGE $MOUNT_POINT + mount_system $2 $3;; - get_image) # get_image $BUILD_DIRECTORY $RPI_ZIP_NAME $RPI_DONWLOAD_URL $RPI_IMAGE_NAME $IMAGE_NAME - get_image $2 $3 $4 $5 $6;; + get_image) # get_image $BUILD_DIR $RPI_DONWLOAD_URL $IMAGE_NAME + get_image $2 $3 $4;; - resize_fs) # resize_fs $SIZE $BUILD_DIRECTORY $IMAGE_NAME $DEV_ROOTFS + resize_fs) # resize_fs $SIZE $BUILD_DIR $IMAGE_NAME resize_fs $2 $3 $4 $5;; - publish_image) # publish_image $BUILD_DIRECTORY $IMAGE_NAME $WORKSPACE $CONFIG_FILE $RELEASE_ID $RELEASE_BODY - publish_image $2 $3 $4 $5 $6 $7;; + publish_image) # publish_image_python $BUILD_DIR $IMAGE_NAME $WORKSPACE $CONFIG_FILE $RELEASE_ID $RELEASE_BODY + publish_image_python $2 $3 $4 $5 $6 $7;; - publish_image2) # publish_image2 $BUILD_DIRECTORY $IMAGE_NAME $WORKSPACE $CONFIG_FILE $RELEASE_ID $RELEASE_BODY - publish_image2 $2 $3 $4 $5 $6 $7;; + publish_image_bash) # publish_image_bash $BUILD_DIR $IMAGE_NAME $WORKSPACE $CONFIG_FILE $RELEASE_ID $RELEASE_BODY + publish_image_bash $2 $3 $4 $5 $6 $7;; - execute) # execute $IMAGE $PREFIX_PATH $DEV_ROOTFS $DEV_BOOT $EXECUTE_FILE - execute $2 $3 $4 $5 $6;; + execute) # execute $IMAGE $MOUNT_POINT $EXECUTE_FILE ... + execute $2 $3 $4 ${@:5};; *) - echo "Enter one of: enter, get_image, resize_fs, publish_image, execute";; + echo "Enter one of: mount_system, get_image, resize_fs, publish_image, execute";; esac diff --git a/image_builder/jenkinsfile-build b/image_builder/jenkinsfile-build new file mode 100644 index 000000000..763cc88a0 --- /dev/null +++ b/image_builder/jenkinsfile-build @@ -0,0 +1,76 @@ +pipeline { + agent any + parameters { + string(name: 'IMAGE_NAME', defaultValue: 'clever_noname.img', description: 'Output image file name') + string(name: 'GWBT_RELEASE_TAG_NAME', defaultValue: "master", description: 'Release tag name') + string(name: 'IMAGE_VERSION', defaultValue: "${params.GWBT_RELEASE_TAG_NAME}", description: 'Image version') + + string(name: 'BUILD_DIR', defaultValue: '/mnt/hdd_builder/workspace', description: 'Build workspace') + string(name: 'MOUNT_POINT', defaultValue: '/mnt/hdd_builder/image', description: 'Mount point') + + string(name: 'RPI_DONWLOAD_URL', defaultValue: 'https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-12-01/2017-11-29-raspbian-stretch-lite.zip') + // TODO: Add mirrorparameters + } + environment { + DEBIAN_FRONTEND = 'noninteractive' + LANG = 'C.UTF-8' + LC_ALL = 'C.UTF-8' + } + stages { + stage('Get image') { + steps { + sh "$WORKSPACE/image_builder/image_config.sh get_image ${params.BUILD_DIR} ${params.RPI_DONWLOAD_URL} ${params.IMAGE_NAME}" + } + } + stage('Resize FS') { + environment { + SIZE = '8G' + } + steps { + sh "$WORKSPACE/image_builder/image_config.sh resize_fs $SIZE ${params.BUILD_DIR} ${params.IMAGE_NAME}" + } + } + stage('Initialize image') { + environment { + EXECUTE_FILE = 'scripts/init_image.sh' + } + // TODO: Transfer apps.sh initialisation code here + steps { + sh "$WORKSPACE/image_builder/image_config.sh execute ${params.BUILD_DIR}/${params.IMAGE_NAME} ${params.MOUNT_POINT} $WORKSPACE/image_builder/$EXECUTE_FILE ${params.IMAGE_VERSION} \$(basename ${params.RPI_DONWLOAD_URL})" + } + } + stage('Hardware setup') { + environment { + EXECUTE_FILE = 'scripts/hardware_setup.sh' + } + steps { + sh "$WORKSPACE/image_builder/image_config.sh execute ${params.BUILD_DIR}/${params.IMAGE_NAME} ${params.MOUNT_POINT} $WORKSPACE/image_builder/$EXECUTE_FILE" + } + } + stage('Software install') { + environment { + EXECUTE_FILE = 'scripts/software_install.sh' + } + steps { + sh "$WORKSPACE/image_builder/image_config.sh execute ${params.BUILD_DIR}/${params.IMAGE_NAME} ${params.MOUNT_POINT} $WORKSPACE/image_builder/$EXECUTE_FILE" + } + } + stage('Network setup') { + environment { + EXECUTE_FILE = 'scripts/network_setup.sh' + } + steps { + sh "$WORKSPACE/image_builder/image_config.sh execute ${params.BUILD_DIR}/${params.IMAGE_NAME} ${params.MOUNT_POINT} $WORKSPACE/image_builder/$EXECUTE_FILE" + } + } + stage('Install ROS') { + environment { + EXECUTE_FILE = 'scripts/ros_install.sh' + } + steps { + sh "$WORKSPACE/image_builder/image_config.sh execute ${params.BUILD_DIR}/${params.IMAGE_NAME} ${params.MOUNT_POINT} $WORKSPACE/image_builder/$EXECUTE_FILE" + } + } + // TODO: Add finalising step, transfer mirror removal from ros.sh + } +} diff --git a/image/Jenkinsfile-release b/image_builder/jenkinsfile-release similarity index 65% rename from image/Jenkinsfile-release rename to image_builder/jenkinsfile-release index 7305b75c9..3c402678f 100644 --- a/image/Jenkinsfile-release +++ b/image_builder/jenkinsfile-release @@ -4,15 +4,18 @@ pipeline { //string(name: 'GWBT_REPO_NAME', defaultValue: 'master', description: 'GWBT_REPO_NAME') //string(name: 'GWBT_RELEASE_TAG_NAME', defaultValue: 'master', description: 'REPO') //string(name: 'GWBT_RELEASE_PUBLISHED_AT', defaultValue: 'master', description: 'GWBT_RELEASE_PUBLISHED_AT') - //string(name: 'GWBT_RELEASE_ID', defaultValue: '', description: 'GWBT_RELEASE_ID') - //string(name: 'GWBT_RELEASE_BODY', defaultValue: '', description: 'GWBT_RELEASE_BODY') + string(name: 'GWBT_RELEASE_ID', defaultValue: '', description: 'GWBT_RELEASE_ID') + string(name: 'GWBT_RELEASE_BODY', defaultValue: '', description: 'GWBT_RELEASE_BODY') string(name: 'IMAGE_NAME', defaultValue: "${params.GWBT_REPO_NAME}_${params.GWBT_RELEASE_TAG_NAME}_${params.GWBT_RELEASE_PUBLISHED_AT}.img", description: 'IMAGE_NAME') - //string(name: 'GWBT_TRIGGER', defaultValue: '', description: 'GWBT_TRIGGER') + string(name: 'GWBT_TRIGGER', defaultValue: 'release', description: 'GWBT_TRIGGER') booleanParam(name: 'ONLY_PUBLISH', defaultValue: false, description: 'ONLY PUBLISH') - //string(name: 'WORKSPACE', defaultValue: '', description: 'WORKSPACE') + + string(name: 'BUILD_DIR', defaultValue: '/mnt/hdd_builder/workspace', description: 'Build workspace') } environment { - BUILD_DIRECTORY = '/home/pi/temp' + DEBIAN_FRONTEND = 'noninteractive' + LANG = 'C.UTF-8' + LC_ALL = 'C.UTF-8' } stages { stage('Build image') { @@ -28,7 +31,7 @@ pipeline { CONFIG_FILE = 'coex-ci.conf' } steps { - sh "$WORKSPACE/image/image-config.sh publish_image $BUILD_DIRECTORY ${params.IMAGE_NAME} $WORKSPACE $CONFIG_FILE ${params.GWBT_RELEASE_ID} ${params.GWBT_RELEASE_BODY}" + sh "$WORKSPACE/image_builder/image_config.sh publish_image ${params.BUILD_DIR} ${params.IMAGE_NAME} $WORKSPACE $CONFIG_FILE ${params.GWBT_RELEASE_ID} \'${params.GWBT_RELEASE_BODY}\'" } } } diff --git a/image/iface.sh b/image_builder/scripts/hardware_setup.sh similarity index 88% rename from image/iface.sh rename to image_builder/scripts/hardware_setup.sh index deccb0fb3..543c06d95 100755 --- a/image/iface.sh +++ b/image_builder/scripts/hardware_setup.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e @@ -43,14 +43,14 @@ CONFIG=/boot/config.txt # 2. Изменить необходимые настройки # 2.1. Включить sshd -echo "\033[0;31m\033[1m$(date) | #11 Turn on sshd\033[0m\033[0m" +echo -e "\033[0;31m\033[1m$(date) | #1 Turn on sshd\033[0m\033[0m" touch /boot/ssh # 2.2. Включить GPIO # Включено по умолчанию # 2.3. Включить I2C -echo "\033[0;31m\033[1m$(date) | #12 Turn on I2C\033[0m\033[0m" +echo -e "\033[0;31m\033[1m$(date) | #2 Turn on I2C\033[0m\033[0m" set_config_var dtparam=i2c_arm on $CONFIG && if ! [ -e $BLACKLIST ]; then @@ -63,7 +63,7 @@ set_config_var dtparam=i2c_arm on $CONFIG && fi # 2.4. Включить SPI -echo "\033[0;31m\033[1m$(date) | #13 Turn on SPI\033[0m\033[0m" +echo -e "\033[0;31m\033[1m$(date) | #3 Turn on SPI\033[0m\033[0m" set_config_var dtparam=spi on $CONFIG && if ! [ -e $BLACKLIST ]; then @@ -72,7 +72,7 @@ set_config_var dtparam=spi on $CONFIG && sed $BLACKLIST -i -e "s/^\(blacklist[[:space:]]*spi[-_]bcm2708\)/#\1/" # 2.5. Включить raspicam -echo "\033[0;31m\033[1m$(date) | #14 Turn on raspicam\033[0m\033[0m" +echo -e "\033[0;31m\033[1m$(date) | #4 Turn on raspicam\033[0m\033[0m" get_config_var() { lua - "$1" "$2" <> /etc/modules fi -# 2.6. Настроить AP wifi -# 2.7. Настроить сеть на wlan -# 2.8. Настроить DHCPd на wlan - - -echo "\033[0;31m\033[1m$(date) | #15 End of configuring interfaces\033[0m\033[0m" +echo -e "\033[0;31m\033[1m$(date) | #5 End of configuring interfaces\033[0m\033[0m" diff --git a/image_builder/scripts/init_image.sh b/image_builder/scripts/init_image.sh new file mode 100755 index 000000000..f85883451 --- /dev/null +++ b/image_builder/scripts/init_image.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -e + +################################################################################################################################## +# Image initialisation +################################################################################################################################## + +# Add apt key to allow local mirror usage during image build +#wget -O - ftp://192.168.0.10/coex-mirror.gpg | apt-key add - +# Generate a backup of the original source.list +#cp /etc/apt/sources.list /var/sources.list.bak +# Add the local mirror as the first priority repository +#wget -O - ftp://192.168.0.10/coex-mirror.list 2>/dev/null | cat - /etc/apt/sources.list > /var/sources.list && mv /var/sources.list /etc/apt/sources.list + +echo -e "\033[0;31m\033[1m$(date) | #1 apt cache update\033[0m\033[0m" + +# Clean repostory cache +apt-get clean +# Update repository cache +apt-get update +# && apt upgrade -y + +echo -e "\033[0;31m\033[1m$(date) | #2 Write clever information\033[0m\033[0m" + +# Clever image version +echo "$1" >> /etc/clever_version +# Origin image file name +echo "${2%.*}" >> /etc/clever_origin + +echo -e "\033[0;31m\033[1m$(date) | #3 End initialisation of image\033[0m\033[0m" diff --git a/image_builder/scripts/network_setup.sh b/image_builder/scripts/network_setup.sh new file mode 100755 index 000000000..af4941af9 --- /dev/null +++ b/image_builder/scripts/network_setup.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +set -e + +echo -e "\033[0;31m\033[1m$(date) | #1 Write to /etc/wpa_supplicant/wpa_supplicant.conf\033[0m\033[0m" + +# TODO: Use wpa_cli insted direct file edit +echo " +network={ + ssid=\"CLEVER\" + mode=2 + key_mgmt=WPA-PSK + psk=\"cleverwifi\" + frequency=2437 +}" >> /etc/wpa_supplicant/wpa_supplicant.conf + +echo -e "\033[0;31m\033[1m$(date) | #2 Write STATIC to /etc/dhcpcd.conf\033[0m\033[0m" + +echo " +interface wlan0 +static ip_address=192.168.11.1/24" >> /etc/dhcpcd.conf + +echo -e "\033[0;31m\033[1m$(date) | #3 Write iface to /etc/default/isc-dhcp-server\033[0m\033[0m" + +# https://www.shellhacks.com/ru/sed-find-replace-string-in-file/ +sed -i 's/INTERFACESv4=\"\"/INTERFACESv4=\"wlan0\"/' /etc/default/isc-dhcp-server + +echo -e "\033[0;31m\033[1m$(date) | #4 Write dhcp declaration subnet to /etc/dhcp/dhcpd.conf\033[0m\033[0m" + +echo "subnet 192.168.11.0 netmask 255.255.255.0 { + range 192.168.11.11 192.168.11.254; + #option domain-name-servers 8.8.8.8; + #option domain-name "rpi.local"; + option routers 192.168.11.1; + option broadcast-address 192.168.11.255; + default-lease-time 600; + max-lease-time 7200; +}" >> /etc/dhcp/dhcpd.conf + +echo -e "\033[0;31m\033[1m$(date) | #5 Write start script for dhcpd to /etc/network/if-up.d/isc-dhcp-server\033[0m\033[0m" + +echo "#!/bin/sh +if [ \"\$IFACE\" = \"--all\" ]; +then sleep 10 && systemctl start isc-dhcp-server.service & +fi +" > /etc/network/if-up.d/isc-dhcp-server \ + && chmod +x /etc/network/if-up.d/isc-dhcp-server + +echo -e "\033[0;31m\033[1m$(date) | #6 Write magic script for rename SSID to /etc/rc.local\033[0m\033[0m" + +RENAME_SSID="sudo sed -i.OLD \"s/CLEVER/CLEVER-\$(head -c 100 /dev/urandom | xxd -ps -c 100 | sed -e 's/[^0-9]//g' | cut -c 1-4)/g\" /etc/wpa_supplicant/wpa_supplicant.conf && sudo sed -i '/sudo sed/d' /etc/rc.local && sudo reboot" + +sed -i "19a$RENAME_SSID" /etc/rc.local + +echo -e "\033[0;31m\033[1m$(date) | #7 End of network installation\033[0m\033[0m" diff --git a/image_builder/scripts/ros_install.sh b/image_builder/scripts/ros_install.sh new file mode 100755 index 000000000..4f5f623de --- /dev/null +++ b/image_builder/scripts/ros_install.sh @@ -0,0 +1,173 @@ +#!/bin/bash + +set -e + +################################################################################################################################## +# ROS for user pi +################################################################################################################################## + +# ros http://wiki.ros.org/action/fullsearch/ROSberryPi/Installing%20ROS%20Kinetic%20on%20the%20Raspberry%20Pi +# maintainer @urpylka + +echo -e "\033[0;31m\033[1m$(date) | #0 Installing ROS\033[0m\033[0m" + +echo -e "\033[0;31m\033[1m$(date) | #1 Installing dirmngr & add key to apt-key\033[0m\033[0m" + +# Install a tool that apt-key uses to add ROS repository key +# http://wpblogger.su/tags/apt/ +apt-get install dirmngr +# setup keys +apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 + +# setup sources.list +echo "deb http://packages.ros.org/ros/ubuntu stretch main" > /etc/apt/sources.list.d/ros-latest.list + +echo -e "\033[0;31m\033[1m$(date) | #2 apt update && apt upgrade\033[0m\033[0m" + +# install bootstrap tools +apt-get update +# && apt upgrade -y + +echo -e "\033[0;31m\033[1m$(date) | #3 Installing wget, unzip, python-rosdep, python-rosinstall-generator, python-wstool, python-rosinstall, build-essential, cmake\033[0m\033[0m" + +apt-get install --no-install-recommends -y \ + wget \ + unzip \ + python-rosdep \ + python-rosinstall-generator \ + python-wstool \ + python-rosinstall \ + build-essential \ + cmake \ + libjpeg8-dev + +echo -e "\033[0;31m\033[1m$(date) | #4 rosdep init && rosdep update\033[0m\033[0m" + +# bootstrap rosdep +rosdep init && rosdep update + +echo -e "\033[0;31m\033[1m$(date) | #5 Preparing ros_comm packages to kinetic-ros_comm-wet.rosinstall\033[0m\033[0m" + +# create catkin workspace +mkdir -p /home/pi/ros_catkin_ws && cd /home/pi/ros_catkin_ws \ + && rosinstall_generator ros_comm --rosdistro kinetic --deps --wet-only --tar > kinetic-ros_comm-wet.rosinstall \ + && wstool init src kinetic-ros_comm-wet.rosinstall + +echo -e "\033[0;31m\033[1m$(date) | #6 Preparing other ROS-packages to kinetic-custom_ros.rosinstall\033[0m\033[0m" + +cd /home/pi/ros_catkin_ws \ + && rosinstall_generator \ + actionlib actionlib_msgs angles async_web_server_cpp bond bond_core bondcpp bondpy camera_calibration_parsers camera_info_manager catkin class_loader cmake_modules cpp_common cv_bridge cv_camera diagnostic_msgs diagnostic_updater dynamic_reconfigure eigen_conversions gencpp geneus genlisp genmsg gennodejs genpy geographic_msgs geometry_msgs geometry2 image_transport libmavconn mavlink mavros_msgs message_filters message_generation message_runtime mk nav_msgs nodelet orocos_kdl pluginlib python_orocos_kdl ros ros_comm rosapi rosauth rosbag rosbag_migration_rule rosbag_storage rosbash rosboost_cfg rosbridge_library rosbridge_server rosbridge_suite rosbuild rosclean rosconsole rosconsole_bridge roscpp roscpp_serialization roscpp_traits roscreate rosgraph rosgraph_msgs roslang roslaunch roslib roslint roslisp roslz4 rosmake rosmaster rosmsg rosnode rosout rospack rosparam rospy rospy_tutorials rosserial rosserial_client rosserial_msgs rosserial_python rosservice rostest rostime rostopic rosunit roswtf sensor_msgs smclib std_msgs std_srvs stereo_msgs tf tf2 tf2_bullet tf2_eigen tf2_geometry_msgs tf2_kdl tf2_msgs tf2_py tf2_ros tf2_sensor_msgs tf2_tools topic_tools trajectory_msgs urdf urdf_parser_plugin usb_cam uuid_msgs visualization_msgs web_video_server xmlrpcpp mavros opencv3 mavros_extras \ + --rosdistro kinetic --deps --wet-only --tar > kinetic-custom_ros.rosinstall \ + && wstool merge -t src kinetic-custom_ros.rosinstall \ + && wstool update -t src + +echo -e "\033[0;31m\033[1m$(date) | #7 Installing dependencies apps with rosdep\033[0m\033[0m" +cd /home/pi/ros_catkin_ws +# There is a risk that umount will fail +set +e +# Successfull unmount flag (false at thismoment) +install_ok=false +# Repeat 5 times +for i in {1..5} +do + # Resolving Dependencies with rosdep + rosdep install -y --from-paths src --ignore-src --rosdistro kinetic -r --os=debian:stretch + # If no problems detected + if [[ $? == 0 ]] + then + echo -e "\033[0;31m\033[1m$(date) | Successfull rosdep install\033[0m\033[0m" + # Set flag + install_ok=true + # Exit loop + break + fi + # Unmount has failed + echo -e "\033[0;31m\033[1m$(date) | Rosdep installation failed\033[0m\033[0m" + # Wait for some time + sleep 2 +done +set -e +# Jenkins job will fail if this condition is not true +[[ "$install_ok" == true ]] +echo -e "\033[0;31m\033[1m$(date) | End of rosdep install\033[0m\033[0m" + + +echo -e "\033[0;31m\033[1m$(date) | #8 Refactoring usb_cam in SRC\033[0m\033[0m" + +sed -i '/#define __STDC_CONSTANT_MACROS/a\#define PIX_FMT_RGB24 AV_PIX_FMT_RGB24\n#define PIX_FMT_YUV422P AV_PIX_FMT_YUV422P' /home/pi/ros_catkin_ws/src/usb_cam/src/usb_cam.cpp + +echo -e "\033[0;31m\033[1m$(date) | #9 Installing GeographicLib datasets\033[0m\033[0m" + +/home/pi/ros_catkin_ws/src/mavros/mavros/scripts/install_geographiclib_datasets.sh + +#echo -e "\033[0;31m\033[1m$(date) | #11 Building light packages on 2 threads\033[0m\033[0m" + +# Build the catkin Workspace +#cd /home/pi/ros_catkin_ws && ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release -j2 --install-space /opt/ros/kinetic --pkg actionlib actionlib_msgs angles async_web_server_cpp bond bond_core bondcpp bondpy camera_calibration_parsers camera_info_manager catkin class_loader cmake_modules cpp_common diagnostic_msgs diagnostic_updater dynamic_reconfigure eigen_conversions gencpp geneus genlisp genmsg gennodejs genpy geographic_msgs geometry_msgs geometry2 image_transport libmavconn mavlink mavros_msgs message_filters message_generation message_runtime mk nav_msgs nodelet orocos_kdl pluginlib python_orocos_kdl ros ros_comm rosapi rosauth rosbag rosbag_migration_rule rosbag_storage rosbash rosboost_cfg rosbridge_library rosbridge_server rosbridge_suite rosbuild rosclean rosconsole rosconsole_bridge roscpp roscpp_serialization roscpp_traits roscreate rosgraph rosgraph_msgs roslang roslaunch roslib roslint roslisp roslz4 rosmake rosmaster rosmsg rosnode rosout rospack rosparam rospy rospy_tutorials rosserial rosserial_client rosserial_msgs rosserial_python rosservice rostest rostime rostopic rosunit roswtf sensor_msgs smclib std_msgs std_srvs stereo_msgs tf tf2 tf2_bullet tf2_eigen tf2_geometry_msgs tf2_kdl tf2_msgs tf2_py tf2_ros tf2_sensor_msgs tf2_tools topic_tools trajectory_msgs urdf urdf_parser_plugin usb_cam uuid_msgs visualization_msgs xmlrpcpp + +#echo -e "\033[0;31m\033[1m$(date) | #12 Building heavy packages\033[0m\033[0m" + +# This command uses less threads to avoid Raspberry Pi freeze +# Build the catkin Workspace +#cd /home/pi/ros_catkin_ws && ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release -j1 --install-space /opt/ros/kinetic --pkg mavros opencv3 cv_bridge cv_camera mavros_extras web_video_server + +echo -e "\033[0;31m\033[1m$(date) | #10 Building packages on 1 thread\033[0m\033[0m" + +# Install builded packages +# WARNING: A major bug was found when using --pkg option (catkin_make_isolated doesn't install environment files) +# TODO: Can we increase threads number with HDD swap? +cd /home/pi/ros_catkin_ws && ./src/catkin/bin/catkin_make_isolated --install -j1 -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic + +echo -e "\033[0;31m\033[1m$(date) | #12 Creating catkin_ws\033[0m\033[0m" + +mkdir -p /home/pi/catkin_ws/src \ + && cd /home/pi/catkin_ws \ + && . /opt/ros/kinetic/setup.sh \ + && catkin init \ + && wstool init /home/pi/catkin_ws/src + +echo -e "\033[0;31m\033[1m$(date) | #13 Installing CLEVER-BUNDLE\033[0m\033[0m" + +cd /home/pi/catkin_ws/src \ + && git clone https://github.com/CopterExpress/clever.git clever \ + && pip install wheel \ + && pip install -r /home/pi/catkin_ws/src/clever/clever/requirements.txt \ + && cd /home/pi/catkin_ws \ + && . /opt/ros/kinetic/setup.sh \ + && catkin_make -j1 \ + && systemctl enable /home/pi/catkin_ws/src/clever/deploy/roscore.service \ + && systemctl enable /home/pi/catkin_ws/src/clever/deploy/clever.service + +echo -e "\033[0;31m\033[1m$(date) | #14 Adding mjpg-streamer at /home/pi\033[0m\033[0m" + +# https://github.com/jacksonliam/mjpg-streamer + +cd /home/pi \ + && git clone https://github.com/jacksonliam/mjpg-streamer.git \ + && cd /home/pi/mjpg-streamer/mjpg-streamer-experimental \ + && make \ + && make install + +echo -e "\033[0;31m\033[1m$(date) | #15 Adding ENV vars\033[0m\033[0m" + +# setup environment +echo "LANG=C.UTF-8" >> /home/pi/.bashrc +echo "LC_ALL=C.UTF-8" >> /home/pi/.bashrc +echo "ROS_DISTRO=kinetic" >> /home/pi/.bashrc +echo "export ROS_IP=192.168.11.1" >> /home/pi/.bashrc + +echo "source /opt/ros/kinetic/setup.bash" >> /home/pi/.bashrc \ + && echo "source /home/pi/catkin_ws/devel/setup.bash" >> /home/pi/.bashrc + +chown -Rf pi:pi /home/pi + +#echo -e "\033[0;31m\033[1m$(date) | #16 Removing local apt mirror\033[0m\033[0m" +# Restore original sources.list +#mv /var/sources.list.bak /etc/apt/sources.list +# Clean apt cache +apt-get clean +# Remove local mirror repository key +#apt-key del COEX-MIRROR + +echo -e "\033[0;31m\033[1m$(date) | #16 END of ROS INSTALLATION\033[0m\033[0m" diff --git a/image_builder/scripts/software_install.sh b/image_builder/scripts/software_install.sh new file mode 100755 index 000000000..c06874f18 --- /dev/null +++ b/image_builder/scripts/software_install.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set -e + +################################################################################################################################## +# Image software installation +################################################################################################################################## + +echo -e "\033[0;31m\033[1m$(date) | #1 Network installing\033[0m\033[0m" + +# TODO: Use dnsmasq instead of isc-dhcp-server +apt-get install --no-install-recommends -y \ + unzip \ + zip \ + ipython \ + screen \ + byobu \ + nmap \ + lsof \ + python-pip \ + git \ + isc-dhcp-server \ + tmux \ + vim \ + ipython3 \ + python3-pip + +echo -e "\033[0;31m\033[1m$(date) | End of network installation\033[0m\033[0m" diff --git a/image/yadisk.py b/image_builder/yadisk.py similarity index 100% rename from image/yadisk.py rename to image_builder/yadisk.py