Old thread, but fantastically helpful. Thought I would share my systemd tmux.conf that is working for me..
[Unit] Description=Tmux Startup After=startups.service [Service] Type=oneshot RemainAfterExit=yes ExecStart=/opt/bin/tmux -C ExecStop=/opt/bin/tmux kill-server KillMode=none [Install] WantedBy=multi-user.target On Wednesday, 17 September 2014 17:38:35 UTC+1, Philip Southam wrote: > > Carl, > > If you trust me, you can download the static binary saving you the trouble > of going through the aforementioned steps via the following link. > > https://objects.dreamhost.com:443/philipsoutham.public/dist/tmux.gz > https://objects.dreamhost.com:443/philipsoutham.public/dist/tmux.gz.sha256 > > > On Wed, Sep 17, 2014 at 1:46 AM, Carl <[email protected] <javascript:>> > wrote: > >> Philip, >> >> Thank you so much for helping me. I never could have figured this out >> without your help. >> >> I'll try to make my own tmux to see if it worked. >> >> On 17 September 2014 05:43, Philip Southam <[email protected] >> <javascript:>> wrote: >> >>> Carl, >>> >>> You can try the following (I realize this may be a little late, but in >>> case others want to do the same). >>> >>> ------------------------------------ >>> Build a static TMUX *(modified from this >>> <http://blog.assarbad.net/20140415/fully-static-build-of-tmux-using-libc-musl-for-linux/>)* >>> >>> On your local system (or system with a build environment), create >>> build-tmux.sh >>> <https://gist.github.com/philipsoutham/95c86cee8777d2cc43ae> with the >>> following conents: >>> >>> #!/usr/bin/env bashpushd $(dirname $0) > /dev/null; CURRABSPATH=$(readlink >>> -nf "$(pwd)"); popd > /dev/null; # Get the directory in which the script >>> residesset -x >>> MUSLPKG="musl:musl.tgz:http://www.musl-libc.org/releases/musl-1.1.4.tar.gz" >>> LEVTPKG="libevent:libevent2.tgz:https://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz" >>> TMUXPKG="tmux:tmux.tgz:http://iweb.dl.sourceforge.net/project/tmux/tmux/tmux-1.9/tmux-1.9a.tar.gz" >>> NCRSPKG="ncurses:ncurses.tgz:http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz" >>> TEMPDIR="$CURRABSPATH/tmp" >>> TMPLIB="tempinstall/lib" >>> TMPINC="tempinstall/include" >>> MUSLCC="$TEMPDIR/musl/tempinstall/bin/musl-gcc" >>> [[ -d "$TEMPDIR" ]] || mkdir "$TEMPDIR" || { echo "FATAL: Could not create >>> $TEMPDIR."; exit 1; }for i in "$MUSLPKG" "$NCRSPKG" "$LEVTPKG" "$TMUXPKG"; >>> do >>> NAME=${i%%:*} >>> i=${i#*:} >>> TGZ=${i%%:*} >>> URL=${i#*:} >>> [[ -d "$TEMPDIR/$NAME" ]] && rm -rf "$TEMPDIR/$NAME" >>> [[ -d "$TEMPDIR/$NAME" ]] || mkdir "$TEMPDIR/$NAME" || { echo "FATAL: >>> Could not create $TEMPDIR/$NAME."; exit 1; } >>> [[ -f "$CURRABSPATH/$TGZ" ]] || curl -o "$CURRABSPATH/$TGZ" "$URL" || >>> wget -O "$CURRABSPATH/$TGZ" "$URL" || { echo "FATAL: failed to fetch >>> $URL."; exit 1; } >>> echo "Unpacking $NAME" && tar --strip-components=1 -C "$TEMPDIR/$NAME" >>> -xf "$TGZ" && mkdir "$TEMPDIR/$NAME/tempinstall" \ >>> || { echo "FATAL: Could not unpack one of the required source >>> packages. Check above output for clues."; exit 1; } >>> echo "Building $NAME (this may take some time)" >>> ( >>> PREFIX="$TEMPDIR/$NAME/tempinstall" >>> case $NAME in >>> musl ) >>> (cd "$TEMPDIR/$NAME" && ./configure --enable-gcc-wrapper >>> --prefix="$PREFIX") && \ >>> make -C "$TEMPDIR/$NAME" && make -C "$TEMPDIR/$NAME" install >>> ;; >>> ncurses ) >>> (cd "$TEMPDIR/$NAME" && ./configure --without-ada >>> --without-cxx --without-progs --without-manpages --disable-db-install >>> --without-tests --with-default-terminfo-dir=/usr/share/terminfo >>> --with-terminfo-dirs="/etc/terminfo:/lib/terminfo:/usr/share/terminfo" >>> --prefix="$PREFIX" CC="$MUSLCC") && \ >>> make -C "$TEMPDIR/$NAME" && make -C "$TEMPDIR/$NAME" install >>> ;; >>> libevent ) >>> (cd "$TEMPDIR/$NAME" && ./configure --enable-static >>> --enable-shared --disable-openssl --prefix="$PREFIX" CC="$MUSLCC") && \ >>> make -C "$TEMPDIR/$NAME" && make -C "$TEMPDIR/$NAME" install >>> ;; >>> tmux ) >>> (cd "$TEMPDIR/$NAME" && ./configure --enable-static >>> --prefix="$PREFIX" CC="$MUSLCC" CPPFLAGS="-I$TEMPDIR/libevent/$TMPINC >>> -I$TEMPDIR/ncurses/$TMPINC -I$TEMPDIR/ncurses/$TMPINC/ncurses" >>> LDFLAGS="-L$TEMPDIR/libevent/$TMPLIB -L$TEMPDIR/ncurses/$TMPLIB" >>> LIBS=-lncurses) && \ >>> make -C "$TEMPDIR/$NAME" && make -C "$TEMPDIR/$NAME" install >>> strip $PREFIX/bin/tmux >>> ;; >>> esac >>> ) 2>&1 |tee "$TEMPDIR/${NAME}.log" > /dev/null || { echo "FATAL: failed >>> to build $NAME. Consult $TEMPDIR/${NAME}.log for details."; exit 1; } >>> unset CCdone >>> >>> Upload to Server >>> >>> And place the binary where you can use it, say /opt/bin/. >>> >>> $ scp tmp/tmux/tempinstall/bin/tmux [email protected]:$ ssh >>> [email protected]$ sudo mv tmux /opt/bin # create this dir if it doesn't >>> exist before moving >>> >>> Run >>> >>> $ sudo systemd-run --gid=core --uid=core -r /bin/sh -c "/opt/bin/tmux -C" >>> $ /opt/bin/tmux a >>> >>> You may be thinking, why not just run it via /opt/bin/tmux without >>> using systemd-run >>> <http://www.freedesktop.org/software/systemd/man/systemd-run.html>? Go >>> ahead and try it. As soon as you disconnect your ssh connection, the tmux >>> session is killed. Running it via systemd-run >>> <http://www.freedesktop.org/software/systemd/man/systemd-run.html> keeps >>> the session around. >>> >>> On Monday, March 10, 2014 8:48:08 AM UTC-7, Carl Su wrote: >>>> >>>> I see. Thank you very much. >>>> >>>> >>>> 2014-03-10 23:04 GMT+08:00 Alex Polvi <[email protected]>: >>>> >>>>> Carl, you might consider writing a systemd unit file, or running >>>>> systemd-run. Having your process controlled by the init system will make >>>>> sure it works regardless of your ssh connection. >>>>> >>>>> Futhermore, a docker pull actually causes the docker daemon to do the >>>>> download... meaning if you lose your ssh connection it will still be >>>>> running. >>>>> >>>>> -Alex >>>>> >>>>> >>>>> On Sun, Mar 9, 2014 at 10:54 PM, Carl Su <[email protected]> wrote: >>>>> >>>>>> I'd like to do some tasks (e.g. docker pull/push) in tmux to make >>>>>> sure that >>>>>> it's running even when I lost my SSH connections. Can I have a tmux >>>>>> installed >>>>>> in CoreOS? If not, what can I do? >>>>>> >>>>> >>>>> >>>> >> >
