From patchwork Wed Mar 9 02:07:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bird, Tim" X-Patchwork-Id: 8541401 Return-Path: X-Original-To: patchwork-ltsi-dev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 63E91C0553 for ; Wed, 9 Mar 2016 02:07:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 276D320211 for ; Wed, 9 Mar 2016 02:07:46 +0000 (UTC) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1C442200E9 for ; Wed, 9 Mar 2016 02:07:45 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0AA2BBF4; Wed, 9 Mar 2016 02:07:45 +0000 (UTC) X-Original-To: ltsi-dev@lists.linuxfoundation.org Delivered-To: ltsi-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id C257ABF4 for ; Wed, 9 Mar 2016 02:07:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from SELDSEGREL01.sonyericsson.com (seldsegrel01.sonyericsson.com [37.139.156.29]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CDF54106 for ; Wed, 9 Mar 2016 02:07:42 +0000 (UTC) To: "ltsi-dev@lists.linuxfoundation.org" From: Tim Bird Message-ID: <56DF8565.9030303@sonymobile.com> Date: Tue, 8 Mar 2016 18:07:33 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org Cc: Artemi Ivanov , Dmitry Cherkasov Subject: [LTSI-dev] [PATCH] Add a script to maintain the symlink for config.xml into, /userdata/conf X-BeenThere: ltsi-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "A list to discuss patches, development, and other things related to the LTSI project" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ltsi-dev-bounces@lists.linuxfoundation.org Errors-To: ltsi-dev-bounces@lists.linuxfoundation.org X-Virus-Scanned: ClamAV using ClamSMTP This adds a feature to maintain the symlink from /var/lib/jenkins/config.xml to /userdata/conf/config.xml. Jenkins removes this symlink when it edits the file (which happens when a board is added or removed). This change adds the inotify-tools package to the container build, and adds a shell script which uses that in order to monitor the directory for changes, and repair the link if needed. A small change is made to the jta-start-cmd.sh to start the script (which runs forever). The script is currently a bit noisy, but I could add a 'quiet' option if desired, so that it runs silently. --- Let me know what you think about this fix. If you'd prefer a different approach for fixing this bug, that's fine. I tested this, and it does work pretty well. Dockerfile | 7 ++++++- jta-scripts/jta-start-cmd.sh | 1 + jta-scripts/maintain_config_link.sh | 38 +++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 jta-scripts/maintain_config_link.sh diff --git a/Dockerfile b/Dockerfile index eab5995..ac3d6fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ ENV URL_PREFIX /jta WORKDIR /jta-install RUN dpkg --add-architecture i386 RUN echo deb http://ftp.us.debian.org/debian jessie main non-free >> /etc/apt/sources.list -RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -yV install apt-utils daemon gcc make python-paramiko python-lxml python-simplejson python-matplotlib libtool xmlstarlet autoconf automake rsync openjdk-7-jre openjdk-7-jdk iperf netperf netpipe-tcp texlive-latex-base sshpass wget git sudo net-tools vim openssh-server curl +RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -yV install apt-utils daemon gcc make python-paramiko python-lxml python-simplejson python-matplotlib libtool xmlstarlet autoconf automake rsync openjdk-7-jre openjdk-7-jdk iperf netperf netpipe-tcp texlive-latex-base sshpass wget git sudo net-tools vim openssh-server curl inotify-tools RUN /bin/bash -c 'echo "dash dash/sh boolean false" | debconf-set-selections ; DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash' COPY frontend-install/jenkins_1.509.2_all.deb /jta-install/ RUN dpkg -i /jta-install/jenkins_1.509.2_all.deb @@ -47,6 +47,11 @@ RUN ln -s $INST_JTA_ENGINE_PATH/jta/jobs $INST_JTA_FRONTEND_PATH/jobs COPY docs $INST_JTA_FRONTEND_PATH/userContent/docs/ # ============================================================================== +# copy a miscelaneous JTA script +# ============================================================================== +COPY jta-scripts/maintain_config_link.sh /usr/local/bin/ + +# ============================================================================== # Init userdata # ============================================================================== diff --git a/jta-scripts/jta-start-cmd.sh b/jta-scripts/jta-start-cmd.sh index 50eb49e..5f67dc2 100755 --- a/jta-scripts/jta-start-cmd.sh +++ b/jta-scripts/jta-start-cmd.sh @@ -4,4 +4,5 @@ /etc/init.d/netperf start /sbin/ifconfig eth0 chown -R jenkins /userdata +exec /usr/local/bin/maintain_config_link.sh & /bin/bash diff --git a/jta-scripts/maintain_config_link.sh b/jta-scripts/maintain_config_link.sh new file mode 100755 index 0000000..bf9815b --- /dev/null +++ b/jta-scripts/maintain_config_link.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# maintain_config_link.sh +# +# maintain_config_link.sh expects /var/lib/jenkins/config.xml to be a symlink +# to /userdata/conf/config.xml. It uses inotifywait to monitor +# /var/lib/jenkins for any change in the link status, and if the link +# disappears it restores the symlink +# +# this needs inotifywait, from the inotify-tools package +# +# this is needed because Jenkins removes the symlink when it edits +# the config.xml file, but we want this file to appear in /userdata +# where it can be accessed (and edited) in the host filesystem + +#set -x + +dest_dir=/var/lib/jenkins +source=/userdata/conf/config.xml +dest=/var/lib/jenkins/config.xml + +function fixlink() +{ + # check for still being a symlink + if [ ! -L "$dest" ]; then + echo $dest is NOT a symlink - fixing it now. + mv -f $dest $source ; + ln -s $source $dest ; + else + echo $dest is a symlink - everything is OK. + fi +} + +fixlink +while true +do + inotifywait -e move $dest_dir && fixlink +done