Skip to content

Instantly share code, notes, and snippets.

@sprhawk
Last active May 23, 2021 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sprhawk/2a7b32c75146331e6f4be2ef149e9506 to your computer and use it in GitHub Desktop.
Save sprhawk/2a7b32c75146331e6f4be2ef149e9506 to your computer and use it in GitHub Desktop.
Start My iOS Backup Service Development tmux environment
#!/bin/bash
SESSION="Work"
WORKROOT=$PWD
IOS_BACKUP=0
CORE_SYSTEM=1
WEBUI=2
PHOTOS=3
OFFCLOUDS=4
# MONITOR=5
YOCTO=5
WORKSPACE=6
PERCENTAGE=20
tmux has-session -t $SESSION
if [ $? -eq 0 ]; then
echo "attach-session $SESSION"
tmux attach-session -t $SESSION
exit 0
fi
tmux new-session -d -c $WORKROOT -s $SESSION
# redis
# tmux new-window -n "redis" -c "$WORKROOT" -t $REDIS
# tmux send-keys "./local/bin/redis-server ./local/etc/redis.conf" Enter
# tmux split-window -h -c "$WORKROOT" -t $REDIS
# tmux send-keys "sleep 5; ./local/bin/redis-cli" Enter
# ios backup service
tmux select-window -t $IOS_BACKUP
tmux rename-window 'ios-backup'
tmux send-keys "source env.sh" Enter
tmux send-keys "cd $WORKROOT/ios-backup-service" Enter
tmux split-window -h -b -p $PERCENTAGE -t $IOS_BACKUP.0 -c "$WORKROOT/ios-backup-service"
tmux send-keys "source ../env.sh" Enter
tmux send-keys "sleep 5; cargo watch -x 'check'" Enter
tmux split-window -v -t $IOS_BACKUP.0 -c "$WORKROOT/ios-backup-service"
tmux send-keys "source ../env.sh" Enter
tmux send-keys "RUST_LIB_BACKTRACE=1 RUST_BACKTRACE=1 RUST_LOG="error,ios_backup_service=debug" cargo run -- start-service" Enter
tmux select-pane -t :$IOS_BACKUP.2
# tmux send-keys "RUST_LIB_BACKTRACE=1 RUST_BACKTRACE=1 RUST_LOG=debug cargo watch -x 'run -- start-local -n -t 1 -p /var/userdata/hongbo/BackupStack-Backup'" Enter
# core system service
tmux new-window -n "core-system" -c "$WORKROOT/core-system-service" -t $CORE_SYSTEM
tmux send-keys "source ../env.sh" Enter
tmux split-window -h -b -p $PERCENTAGE -t $CORE_SYSTEM.0 -c "$WORKROOT/core-system-service"
tmux send-keys "sleep 5; cargo watch -x 'check'" Enter
tmux split-window -v -t $CORE_SYSTEM.0 -c "$WORKROOT/core-system-service"
tmux send-keys "source ../env.sh" Enter
tmux send-keys "cargo build" Enter
tmux send-keys "sudo RUST_LOG="error,core_system_service=debug" ./target/debug/core-system-service --mounted-root /var/userdata/hongbo/BackupStack-Backup-MountTarget -u hongbo -g hongbo --monitor-disks --monitor-bus-ata" Enter
# to input sudo password
tmux select-pane -t :$CORE_SYSTEM.1
#webui-rs
tmux new-window -n "webui" -c "$WORKROOT/webui-rs" -t $WEBUI
tmux send-keys "source ../env.sh" Enter
# tmux send-keys "" Enter
# use -b to split new pane to the left
tmux split-window -b -h -p $PERCENTAGE -t $WEBUI.0 -c "$WORKROOT/webui-rs"
tmux send-keys "RUST_LOG=debug cargo watch -i .git -x 'run -- --use-manifest --watch-templates'" Enter
tmux split-window -v -t $WEBUI.0 -c "$WORKROOT/webui-f2e"
tmux send-keys "yarn" Enter
tmux send-keys "yarn dev" Enter
tmux select-pane -t :$WEBUI.2
# photos-library
tmux new-window -n "photos" -c "$WORKROOT/photos-library-rs" -t $PHOTOS
tmux send-keys "source ../env.sh" Enter
tmux split-window -h -b -p $PERCENTAGE -t $PHOTOS.0 -c "$WORKROOT/photos-library-rs"
tmux send-keys "source ../env.sh" Enter
tmux send-keys "RUST_LIB_BACKTRACE=1 RUST_BACKTRACE=1 RUST_LOG=error,photos_library=trace cargo run --bin photos-library -- -p photos-library.db -r /var/userdata/hongbo/BackupStack-Backup/offclouds/PhotosLibrary/" Enter
tmux select-pane -t :$PHOTOS.1
# offclouds-web
tmux new-window -n "offclouds" -c "$WORKROOT/offclouds-web" -t $OFFCLOUDS
tmux send-keys "source ../env.sh" Enter
# system-monitor-service
# tmux new-window -n "monitor" -c "$WORKROOT/system-monitor-service" -t $MONITOR
# tmux send-keys "source ../env.sh" Enter
# yocto
tmux new-window -n "yocto" -c "$WORKROOT/backupstack-yocto" -t $YOCTO
tmux send-keys "source poky/oe-init-build-env backupstack-build" Enter
# not usable
# tmux send-keys "source setup-bitbake-server.sh" Enter
tmux split-window -h -t $YOCTO.0 -c "$WORKROOT/backupstack-yocto"
tmux send-keys "ls" Enter
# works
tmux new-window -n "work" -c "$WORKROOT" -t $WORKSPACE
tmux send-keys "source env.sh" Enter
tmux send-keys "./local/bin/redis-server local/etc/redis.conf" Enter
# select Core System Pane which requires sudo password
tmux select-window -t $CORE_SYSTEM
tmux attach -t $SESSION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment