Skip to content

Instantly share code, notes, and snippets.

@codehz
Last active February 6, 2019 10:53
Show Gist options
  • Save codehz/c6887d20e936cd089ecbb2d9d14e60d3 to your computer and use it in GitHub Desktop.
Save codehz/c6887d20e936cd089ecbb2d9d14e60d3 to your computer and use it in GitHub Desktop.
run StoneServer w/o docker
#!/bin/bash -e
printf "%s\n" "Clean up..."
rm -rf output
printf "%s\n" "Downloading..."
wget -q --show-progress -O stone.zip https://gitlab.com/codehz/StoneServer/builds/artifacts/master/download?job=job_package
printf "%s\n" "Unziping..."
unzip stone.zip > /dev/null
(cd output; tar cBf - . | (cd ..; tar xBf -))
rm -rf output
mkdir -p data
if [ ! -d game ]; then
printf "%s\n" "You need download the game folder by self"
else
printf "%s\n" "done!"
fi
#!/bin/bash
set -euo pipefail
cd $(dirname "$0")
if command -v dbus-daemon >/dev/null 2>&1; then
printf "dbus-daemon detected: %s\n" $(which dbus-daemon)
else
printf "dbus-daemon not found!\n"
exit 1
fi
if [ ! -e tmux ]; then
if command -v tmux > /dev/null 2>&1; then
tmux_path=$(which tmux)
printf "tmux detected: %s\n" $(which tmux)
sed 's/─/▄/g' $tmux_path > $PWD/tmux
chmod +x $PWD/tmux
else
printf "tmux not found!\n"
exit 1
fi
fi
if [ ! -d game ]; then
printf "You need download the game folder by self\n"
exit 2
fi
mkdir -p logs
function tm() {
./tmux -S $PWD/stone.socket -f $PWD/tmux.conf "$@"
}
COLOR1="colour183"
COLOR2="colour54"
if [ -f .custom ] ; then
. .custom
fi
cat >tmux.conf <<EOF
# Generated by script
# Don't modify this file!!
unbind-key -a
bind-key -T root C-c set-hook pane-died kill-server \; send-keys -t 0.0 C-c \; send-keys -t 0.1 C-c
bind-key -T root C-d detach-client
bind-key -T root C-r send-keys -t 0.1 C-c
bind-key -T root C-s command-prompt -p 'save content to file: ' -I '$PWD/stone.log' 'capture-pane -t 0.1 -S -32767 ; save-buffer %1 ; delete-buffer'
bind-key -T root Space copy-mode
bind-key -T root ? copy-mode \; command-prompt -i -I "#{pane_search_string}" -p "(search up)" "send -X search-backward-incremental \"%%%\""
bind-key -T root / copy-mode \; command-prompt -i -I "#{pane_search_string}" -p "(search down)" "send -X search-forward-incremental \"%%%\""
bind-key -T root WheelUpPane copy-mode \; send-keys -X scroll-up
bind-key -T root WheelDownPane display-message "Wheelup"
bind-key -T copy-mode WheelUpPane send-keys -X scroll-up
bind-key -T copy-mode WheelDownPane send-keys -X scroll-down
set-option -g exit-empty on
set-option -g window-active-style 'fg=black,bg=$COLOR1'
set-option -g message-command-style 'fg=white,bg=$COLOR2'
set-option -g message-style 'fg=white,bg=$COLOR2'
set-option -g prefix none
set-option -g prefix2 none
set-option -g status off
set-option -g mouse on
set-option -g prefix none
set-option -g focus-events on
set-option -g mode-style "fg=white,bg=$COLOR2"
set-window-option -g pane-border-style 'fg=$COLOR1'
set-window-option -g pane-active-border-style 'fg=$COLOR1'
set-window-option -g aggressive-resize on
set-window-option -g monitor-activity on
set-window-option -g pane-border-format "test"
set-window-option -g remain-on-exit on
set-hook -g client-attached "resize-pane -t 0.0 -y 2"
set-hook -g client-resized "resize-pane -t 0.0 -y 2"
set-hook -g pane-focus-in "resize-pane -t 0.0 -y 2"
EOF
LASTEXIT="capture-pane -t 0.1 -S -32767 ; save-buffer lastexit.log ; delete-buffer"
TM="tmux -S $PWD/stone.socket"
WELCOME="Welcome to use StoneServer launcher script\n\
C-c: exit; C-d: detach; C-r: restart; C-s: save log; Space: copy mode"
SETTTY="stty -echo quit undef erase undef kill undef eof undef start undef stop undef susp undef rprnt undef werase undef lnext undef discard undef"
STARTSTONE="./wrapper ./stone"
RESTART="$SETTTY 2>/dev/null; $STARTSTONE 0<&-"
inline_script="dbus-daemon --print-address --nofork --address unix:path=$PWD/bus --session | (\
grep -m 1 -P '(?<=^unix:path=)[^,]+' && \
clear && \
printf '$WELCOME' && \
$TM set-hook pane-died \"$LASTEXIT ; respawn-pane -t 0.1\" && \
$TM split-window -v \"$RESTART\" && \
$TM resize-pane -t 0.0 -y 2)"
function init_tmux() {
tm new-session -d -s stone "$inline_script"
tm select-layout main-horizontal
tm display-message -t stone:0 "Waiting for dbus"
tm select-window -t stone:0
}
tm has-session -t stone >/dev/null 2>&1 || init_tmux
tm -2 attach-session -t stone
@codehz
Copy link
Author

codehz commented Feb 6, 2019

please use docker version

image: codehz/stoneserver
volume: /run/game (for apk) /run/data /tmp/apid.socket (for redis server)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment