-
Notifications
You must be signed in to change notification settings - Fork 1
/
.bashrc_generic
793 lines (685 loc) · 21.5 KB
/
.bashrc_generic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
#!/bin/bash
#
# Generic bashrc to be sourced from main .bashrc
#
#
# Enable bash completion
#
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
#
# stty
#
# -ixon -ixoff: to remove XON/OFF to release Ctrl-s and Ctrl-q
# -ctlecho : to remove echo of Ctrl-c (^C)
# globstar : to use ** for recursive pattern
#
if [ -t 0 ]; then # If not running interactively, don't do anything
stty -ixon -ixoff -ctlecho
fi
shopt -s globstar
# recommended from tmux-continium for a better bash-history
HISTCONTROL=ignoreboth
#
# Using vim to read man pages (vman command)
# Use vman command insted of normal man
#
vman()
{
vim -c "Man $*" -c "silent only" -c "nmap q :q!<cr>"
}
#
# Add paths of the home sdk
#
export PATH=.:$PATH
os_filename="/etc/os-release"
if [ -f $os_filename ]; then
source $os_filename
os_codename=$ID-$VERSION_ID
export PATH=$HOME/usr-$os_codename/bin:$PATH
export GOPATH=$HOME/usr-$os_codename
else
echo "$os_filename not found"
fi
export EDITOR='vim'
# Alias
alias ll='ls -lh'
alias la='ls -lha'
alias eduroam='sudo wpa_supplicant -Dwext -iwlp2s0 -c /home/agil/.cat_installer/cat_installer.conf'
#
# Colored Prompt Command
#
# Git - from http://blog.deadlypenguin.com/blog/2013/10/24/adding-git-status-to-bash/
# Venv
# return code
# colors based on userid and docker or singularity
#
export ENABLE_PROMPT_GIT=1 # set it to 0 in the terminal to disable the git prompt
export ENABLE_PROMPT_ERR=1 # set it to 0 in the terminal to disable the return code error prompt
export ENABLE_PROMPT_VENV=1 # set it to 0 in the terminal to disable the venv prompt
export ENABLE_PROMPT_SLURM=1 # set it to 0 in the terminal to disable the slurm prompt
#
# Define some colors first: Capitals denote bold
#
red='\e[0;31m'
RED='\e[1;31m'
green='\e[0;32m'
GREEN='\e[1;32m'
yellow='\e[0;33m'
YELLOW='\e[1;33m'
blue='\e[0;34m'
BLUE='\e[1;34m'
magenta='\e[0;35m'
MAGENTA='\e[1;35m'
cyan='\e[0;36m'
CYAN='\e[1;36m'
NC='\e[0m' # No Color
# Taken from http://www.opinionatedprogrammer.com/2011/01/colorful-bash-prompt-reflecting-git-status/
function _git_prompt()
{
if [[ "$ENABLE_PROMPT_GIT" == 1 ]]; then
local git_status="`git status -unormal 2>&1`"
if ! [[ "$git_status" =~ ot\ a\ git\ repo ]]; then
if [[ "$git_status" =~ nothing\ to\ commit ]]; then
local ansi=$GREEN
elif [[ "$git_status" =~ nothing\ added\ to\ commit\ but\ untracked\ files\ present ]]; then
local ansi=$YELLOW
else
local ansi=$RED
fi
if [[ "$git_status" =~ On\ branch\ ([^[:space:]]+) ]]; then
branch=${BASH_REMATCH[1]}
#test "$branch" != master || branch=' '
else
# Detached HEAD. (branch=HEAD is a faster alternative.)
branch="(`git describe --all --contains --abbrev=4 HEAD 2> /dev/null ||
echo HEAD`)"
fi
echo -n '[\['"$ansi"'\]'"$branch"'\[\e[0m\]] '
fi
fi
}
function _virtualenv_prompt()
{
if [[ "$ENABLE_PROMPT_VENV" == 1 ]]; then
if [[ $VIRTUAL_ENV ]] ; then
BASE_VENV=`basename $VIRTUAL_ENV`
echo -ne "(\[$CYAN\]$BASE_VENV\[$NC\]) "
fi
fi
}
function _slurm_prompt()
{
if [[ "$ENABLE_PROMPT_SLURM" == 1 ]]; then
if [[ $SLURM_SETUP_VER ]] ; then
echo -ne "{\[$CYAN\]$SLURM_SETUP_VER\[$NC\]} "
fi
fi
}
function report_errcode()
{
RET_CODE=$?
if [[ "$ENABLE_PROMPT_ERR" == 1 ]]; then
COLOR=$NC
if [[ $RET_CODE -ne 0 ]] ; then
COLOR=$RED
fi
echo -ne "[\[$COLOR\]$RET_CODE\[$NC\]] "
fi
}
function report_location()
{
if [ -z "$DOCKER" ] && [ -z "$SINGULARITY_NAME" ]; then
if [ "$UID" == 0 ]; then
echo -ne "\[$RED\]\u@\h\[$NC\]:\[$BLUE\]\w\[$NC\]"
else
echo -ne "\[$GREEN\]\u@\h\[$NC\]:\[$BLUE\]\w\[$NC\]"
fi
else
echo -ne "\[$YELLOW\]\u@\h\[$NC\]:\[$MAGENTA\]\w\[$NC\]"
fi
}
# export PS2="\[$NC\]> "
export _PS1=">> "
export PS1=$_PS1
export PROMPT_COMMAND='_errcode=$(report_errcode);export PS1="${_errcode}$(_virtualenv_prompt)$(_slurm_prompt)$(_git_prompt)$(report_location)${_PS1}";unset _errcode;'
#
# Rclone helpers
#
rclone-pull()
{
rclone_filter="";
local_path=`realpath "./${1}"`
rclone_path="${local_path}"
rclone_remote=`echo ${PWD/#$HOME/} | cut -d "/" -f2`;
rclone_path=`echo ${rclone_path/#$HOME\/$rclone_remote/}`;
if [ -f "${local_path}" ]; then
is_file=1
else
if [ -d "${local_path}" ]; then
is_file=0
else
# echo "Getting remote size..."
# is_file=`rclone size "${rclone_remote}:${rclone_path}" | grep objects | sed 's/Total objects: //'`
rclone rmdir "${rclone_remote}:${rclone_path}" --dry-run
is_file=$?
fi
fi
if [ "${is_file}" == 1 ]; then
local_path=`dirname "${local_path}"`
else
rclone_filter=${HOME}/${rclone_remote}/.rclone.filter
if [ -e ${rclone_filter} ]; then
rclone_filter=" --filter-from ${rclone_filter}"
else
rclone_filter=""
fi
fi
cmd=`echo rclone sync \"${rclone_remote}:${rclone_path}\" \"${local_path}\" --drive-skip-gdocs --track-renames ${rclone_filter} ${@:2}`;
echo $cmd;
rclone sync "${rclone_remote}:${rclone_path}" "${local_path}" --drive-skip-gdocs --track-renames ${rclone_filter} ${@:2} --dry-run ;
echo "Overwriting LOCAL files. Sure?";
read sure;
if [ "$sure" = "y" ]; then
rclone sync "${rclone_remote}:${rclone_path}" "${local_path}" --drive-skip-gdocs --track-renames ${rclone_filter} ${@:2} -v;
else
echo "Aborted";
fi;
}
rclone-push()
{
rclone_filter="";
local_path=`realpath "./${1}"`
rclone_remote=`echo ${PWD/#$HOME/} | cut -d "/" -f2`;
if [ -f "${local_path}" ]; then
rclone_path=`dirname "${local_path}"`
else
rclone_path="${local_path}"
rclone_filter=${HOME}/${rclone_remote}/.rclone.filter
if [ -e ${rclone_filter} ]; then
rclone_filter=" --filter-from ${rclone_filter}"
else
rclone_filter=""
fi
fi
rclone_path=`echo ${rclone_path/#$HOME\/$rclone_remote/}/`;
cmd=`echo rclone sync \"${local_path}\" \"${rclone_remote}:${rclone_path}\" --drive-skip-gdocs --track-renames ${rclone_filter} ${@:2}`;
echo $cmd;
rclone sync "${local_path}" "${rclone_remote}:${rclone_path}" --drive-skip-gdocs --track-renames ${rclone_filter} ${@:2} --dry-run;
echo "Overwriting REMOTE files. Sure?";
read sure;
if [ "$sure" = "y" ]; then
rclone sync "${local_path}" "${rclone_remote}:${rclone_path}" --drive-skip-gdocs --track-renames ${rclone_filter} ${@:2} -v;
else
echo "Aborted";
fi;
}
rclone-status()
{
rclone_filter="";
local_path=`realpath "./${1}"`
rclone_remote=`echo ${PWD/#$HOME/} | cut -d "/" -f2`;
if [ -f "${local_path}" ]; then
rclone_path=`dirname "${local_path}"`
else
rclone_path="${local_path}"
rclone_filter=${HOME}/${rclone_remote}/.rclone.filter
if [ -e ${rclone_filter} ]; then
rclone_filter=" --filter-from ${rclone_filter}"
else
rclone_filter=""
fi
fi
rclone_path=`echo ${rclone_path/#$HOME\/$rclone_remote/}/`;
cmd=`echo rclone check \"${local_path}\" \"${rclone_remote}:${rclone_path}\" --ignore-size --drive-skip-gdocs --track-renames ${rclone_filter} ${@:2}`;
echo $cmd;
rclone check "${local_path}" "${rclone_remote}:${rclone_path}" --ignore-size --drive-skip-gdocs --track-renames ${rclone_filter} ${@:2};
}
#
# Simpler gcloud downloader (public files only)
#
gcloud-download ()
{
if [ "$2" == "" ]; then
echo "Usage: $0 doc_id outfile"
return 1
fi
id=$1
outfile=$2
cookiefile=/tmp/gloudcookie-${id}.txt
cmd="wget --quiet --save-cookies $cookiefile --keep-session-cookies --no-check-certificate \
'https://docs.google.com/uc?export=download&id=$id' -O- | \
sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p'"
confirm=`eval $cmd`
wget --load-cookies $cookiefile "https://docs.google.com/uc?export=download&confirm=${confirm}&id=${id}" \
-O ${outfile}
rm -rf $cookiefile
}
#
# Scan helpers
#
scan-tiff()
{
if [ "$1" == "" ]; then
echo "Please specfy the filename of the tiff file (without extension)"
return 1
fi
scanimage --format tiff -p --mode Color --resolution 400 > $1.tiff
}
scan-tiff2pdf()
{
if [ "$3" == "" ]; then
echo "Usage: $0 lang output.pdf file-01.tiff file-02.tiff... (lang: spa, cat, eng..)"
return 1
fi
lang=$1
outfile=$2
echo "lang =" $lang
echo "outfile =" $outfile
shift
shift
pdfs=()
for file in $*; do
echo OCR+PDF on $file...
basename=`echo "$file" | cut -d'.' -f1`
extension=`echo "$file" | cut -d'.' -f2`
# echo filename = $basename
# echo extension = $extension
tesseract --psm 1 -l $lang $file $basename pdf
pdf=$basename.pdf
echo pdf = $pdf
pdfs+=($pdf)
echo pdfs = ${pdfs[@]}
done
# for pdf in ${pdfs[@]}; do
# echo $pdf
# done
echo Generating $outfile from ${pdfs[@]}
pdfunite ${pdfs[@]} $outfile
acroread $outfile
}
#
# Tmux(inator) helper
#
tmux-slurm()
{
if [ "$1" == "" ] && [ "$SLURM_SETUP_VER" == "" ]; then
echo "Please specify the version as argument."
return 1
fi
if [ "$SLURM_SETUP_VER" == "" ] || [ "$1" != "" ]; then
export SLURM_SETUP_VER=$1
fi
if [ "$2" != "" ]; then
BUG_NUM="bug=$2"
fi
# tmuxinator start slurm -n slurm-$SLURM_SETUP_VER $SLURM_SETUP_VER
# tmux set-environment -t slurm-$SLURM_SETUP_VER SLURM_SETUP_VER $SLURM_SETUP_VER
# tmux attach -t slurm-$SLURM_SETUP_VER
# tmux set-environment -t slurm-$SLURM_SETUP_VER SLURM_SETUP_VER $SLURM_SETUP_VER || tmuxinator start slurm -n slurm-$SLURM_SETUP_VER $SLURM_SETUP_VER
tmuxinator start slurm -n slurm-$SLURM_SETUP_VER $BUG_NUM $SLURM_SETUP_VER
tmux set-environment -t slurm-$SLURM_SETUP_VER SLURM_SETUP_VER $SLURM_SETUP_VER
tmux attach -t slurm-$SLURM_SETUP_VER
}
slurm-docker()
{
if [ "$1" == "" ]; then
echo "Please specify the name of the OS/Docker image as 2nd argument (eg ubuntu)."
return 1
fi
if [ "$2" == "" ]; then
echo "Please specify the version of the OS/Docker image as 2nd argument (eg 20.10)."
return 1
fi
docker build -t slurm-$1:$2 ~/workspace/dotfiles/docker/$1-$2 && \
docker run -it -v ~/workspace/docker/$1-$2-home:/home/$USER \
-v ~/workspace/docker/$1-$2-sdk:/usr/local \
-v /home/$USER/workspace/slurm:/mnt/host \
-v /root:/root \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=$DISPLAY \
--privileged=true \
slurm-$1:$2 \
/bin/bash
}
slurm-atf()
{
atf_user=atf
if [ "$1" != "" ]; then
atf_user=$1
fi
cmd=${@:2}
slurm_repo_dir_atf="/home/slurm/software/slurm-git"
tmp_dir="/tmp/${SLURM_BUG_ID}"
# Check and ensure that the container exists and it's running
status=`lxc info ${SLURM_BUG_ID} 2>&1 | grep Status: | awk '{print $2}'`
if [ "$status" == "" ]; then
if [ -d "${tmp_dir}" ]; then
echo "Removing ${tmp_dir}"
rm -rf ${tmp_dir}
fi
echo "Launching new container: ${SLURM_BUG_ID}"
${SLURM_ATF_PATH}/bin/launch-testsuite -s ${SLURM_SLURM_DIR} -a ${SLURM_ATF_PATH} -kn ${SLURM_BUG_ID} -j6
elif [ "$status" != "Running" ]; then
echo "Starting existing container: ${SLURM_BUG_ID} (${status})"
lxc start ${SLURM_BUG_ID}
fi
# Assuming the container is running from now on
if [ "$cmd" == "" ]; then
cmd=bash
echo "Attaching to a running container ${SLURM_BUG_ID} as user ${atf_user}"
else
echo "Running command in container ${SLURM_BUG_ID} as user ${atf_user}: $cmd"
fi
lxc exec ${SLURM_BUG_ID} -- sudo su ${atf_user} --login --pty --command "cd ${slurm_repo_dir_atf}; export SLURM_TESTSUITE_CONF=/opt/slurm/etc/testsuite.conf; $cmd"
}
slurm-build-makeprg()
{
use_container=false
if [ "$1" == "host" ]; then
use_container=false
else
if [ "$1" == "atf" ]; then
use_container=true
else
status=`lxc info ${SLURM_BUG_ID} 2>&1 | grep Status: | awk '{print $2}'`
if [ "$status" != "" ]; then
use_container=true
fi
fi
fi
if [ $use_container = true ]; then
echo "Building in a container"
make_launcher="slurm-atf slurm slurm-build-make"
# TODO: cscope
else
# No container
echo "Building in the host"
make_launcher="${SLURM_ATF_PATH}/slurm-build-make"
fi
bear --append -o ./compile_commands.json bash -ic "${make_launcher} $SLURM_SLURM_DIR"
}
slurm-docker-ubuntu-2010()
{
slurm-docker ubuntu 20.10
}
digipatics-docker-dev()
{
image=image-dev
if [ "$1" != "" ]; then
image=$1
fi
GID=`id -g`
docker build --target $image -t digipatics-$image \
~/workspace/happy/digipatics/home/workspace/3DHistech && \
\
docker run -it -v ~/workspace/happy/digipatics/home:/home/$USER \
-v ~/workspace/happy/digipatics/home/shared:/mnt/digipatics \
-v /home/$USER:/mnt/host \
-v /root:/root \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=$DISPLAY \
--privileged=true \
digipatics-$image \
/bin/bash -c "addgroup --gid $GID $USER && \
useradd --gid $GID --uid $UID --shell /bin/bash $USER && \
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
echo 'DOCKER=1' >> /etc/environment && \
cd /home/$USER && \
sudo -u $USER /bin/bash"
}
digipatics-docker-prod()
{
image=image-prod
docker build --target $image -t digipatics-$image \
~/workspace/happy/digipatics/home/workspace/3DHistech && \
\
docker run --privileged=true \
-v ~/workspace/happy/digipatics/home/shared:/mnt/digipatics \
digipatics-$image \
$*
}
tmux-slurm-run()
{
if [ "$1" == "" ] && [ "$SLURM_SETUP_VER" == "" ]; then
echo "Please specify the version as argument."
return 1
fi
if [ "$SLURM_SETUP_VER" == "" ] || [ "$1" != "" ]; then
export SLURM_SETUP_VER=$1
fi
tmux new-session -t "slurm-$SLURM_SETUP_VER" -s slurm-$SLURM_SETUP_VER-run || tmux attach -t slurm-$SLURM_SETUP_VER-run
}
tmux-slurm-bug()
{
bug=$1
SLURM_BUG_PATH=~/workspace/slurm/bugs/$bug
mkdir -p $SLURM_BUG_PATH
touch $SLURM_BUG_PATH/.vimprj
tmux new-window -n "$bug" -c $SLURM_SLURM_DIR -a -t "run"
tmux split-window -c $SLURM_SLURM_DIR
tmux split-window -c $SLURM_SLURM_DIR
tmux split-window -c $SLURM_SLURM_DIR
tmux split-window -c $SLURM_SLURM_DIR
# tmux select-layout "7384,274x70,0,0{161x70,0,0[161x61,0,0,386,161x8,0,62,387],112x70,162,0[112x61,162,0,389,112x8,162,62,390]}"
tmux select-layout "42c3,274x70,0,0{161x70,0,0[161x61,0,0,288,161x8,0,62,289],112x70,162,0[112x30,162,0,290,112x30,162,31,292,112x8,162,62,291]}"
tmux select-pane -t 1
tmux send-keys -t 1 "#vim --servername bug-$bug-$SLURM_SETUP_VER" Enter
tmux send-keys -t 1 "vim NEWS" Enter ":OpenSession bug-$bug-$SLURM_SETUP_VER" Tab Enter ":SaveSession bug-$bug-$SLURM_SETUP_VER" Tab Enter
tmux send-keys -t 2 "git status -uno" Enter
tmux send-keys -t 3 "cd testsuite/expect" Enter
tmux send-keys -t 4 "cd testsuite/python" Enter
tmux send-keys -t 5 "cd $SLURM_BUG_PATH" Enter
tmux send-keys -t 5 "ls -lha" Enter
}
#
# Slurm helpers
#
# ToDo: Use EnvModules?
#
slurm-setup()
{
if [ "$1" == "" ] && [ "$SLURM_SETUP_VER" == "" ]; then
echo "Please specify the version as argument."
return 1
fi
if [ "$SLURM_SETUP_VER" == "" ] || [ "$1" != "" ]; then
export SLURM_SETUP_VER=$1
fi
base_path=$HOME/workspace/slurm/$SLURM_SETUP_VER
bug=`tmux display-message -p '#W'`
export SLURM_LOCAL_DIR=${base_path}/local
export SLURM_BUILD_DIR=${base_path}/build
export SLURM_SLURM_DIR=${base_path}/slurm
export SLURM_BUG_PATH=~/workspace/slurm/bugs/$bug
export SLURM_BUG_ID=bug${bug}-${SLURM_SETUP_VER}
export SLURM_LOCAL_GLOBALS_FILE=${SLURM_LOCAL_DIR}/etc/globals.local
export SLURM_TESTSUITE_CONF=${SLURM_LOCAL_DIR}/etc/testsuite.conf
export SLURM_ATF_PATH="$HOME/workspace/slurm/atf"
export PATH=${SLURM_LOCAL_DIR}/bin:$PATH
export PATH=${SLURM_LOCAL_DIR}/sbin:$PATH
export MANPATH=${SLURM_LOCAL_DIR}/share/man:$MANPATH
mkdir -p ${SLURM_LOCAL_DIR}/lib/security
mkdir -p ${SLURM_LOCAL_DIR}/var/log
mkdir -p ${SLURM_LOCAL_DIR}/var/run
mkdir -p ${SLURM_LOCAL_DIR}/var/spool
mkdir -p ${SLURM_LOCAL_DIR}/tmp
mkdir -p ${SLURM_LOCAL_DIR}/tmp/slurmd-tmpfs-c1
mkdir -p ${SLURM_LOCAL_DIR}/tmp/slurmd-tmpfs-c2
mkdir -p ${SLURM_LOCAL_DIR}/tmp/slurmd-tmpfs-c3
mkdir -p ${SLURM_LOCAL_DIR}/tmp/slurmd-tmpfs-c4
if [ ! -L ${SLURM_LOCAL_DIR}/etc ]; then
ln -s ../etc ${SLURM_LOCAL_DIR}/etc
fi
source ${SLURM_SLURM_DIR}/contribs/slurm_completion_help/slurm_completion.sh
}
slurm-slurmd-start()
{
if [ "$1" == "" ] || [ "$2" == "" ] || [ "$3" == "" ]; then
echo "Please specify the prefix and range of nodes prefixN as argument. E.g. $0 c 5 8"
return 1
fi
prefix=$1
first=$2
last=$3
for node in $(seq $first $last); do echo ${prefix}${node}; $SLURM_LOCAL_DIR/sbin/slurmd -vvvN ${prefix}${node}; done
}
slurm-slurmd-stop()
{
if [ "$1" == "" ] || [ "$2" == "" ] || [ "$3" == "" ]; then
echo "Please specify the prefix and range of nodes prefixN as argument. E.g. $0 c 5 8"
return 1
fi
prefix=$1
first=$2
last=$3
for node in $(seq $first $last); do echo ${prefix}${node}; kill `ps aux | grep $SLURM_LOCAL_DIR/sbin/slurmd | grep ${prefix}${node} | awk '{print $2}'`; done
}
slurm-sacctmgr-config()
{
cluster=`sacctmgr show cluster -nP format=cluster`
sacctmgr -i add Account acct Cluster=$cluster
sacctmgr -i add User $USER account=acct
}
slurm-configure()
{
rm -rf $SLURM_BUILD_DIR
mkdir -p $SLURM_BUILD_DIR
cd $SLURM_BUILD_DIR
$SLURM_SLURM_DIR/configure --prefix=$SLURM_LOCAL_DIR \
--enable-developer \
--enable-multiple-slurmd \
--with-hdf5 \
--with-pam_dir=$SLURM_LOCAL_DIR/lib/security \
--with-pmix=/usr/local/opt/openpmix-3.1.6
cd -
}
slurm-check()
{
# Get parameters
if [ $# -eq 0 ]; then
echo "Usage: ${FUNCNAME[0]} test_name|all [silent|minimal|normal|verbose] [fork|nofork]"
return 1
fi
if [ "$1" == "all" ]; then
SLURM_CHECK_LOG=*
else
SLURM_CHECK_LOG=$1
fi
if [ $# -gt 1 ]; then
CK_VERBOSITY=$2
fi
if [ $# -gt 2 ]; then
CK_VERBOSITY=$3
if [ "$2" == "fork" ]; then
CK_FORK=yes
else
CK_FORK=no
fi
fi
# Remove old logs to be sure that we are seeing something that run
rm -f $SLURM_BUILD_DIR/testsuite/slurm_unit/**/*-test.log
# Export dafault environmanet variables for check
# CK_VERBOSITY: "silent", "minimal", "normal", "verbose"
# CK_FORK : Yes or No
if [ -z "$CK_VERBOSITY" ]; then
export CK_VERBOSITY=verbose
else
export CK_VERBOSITY=$CK_VERBOSITY
fi
if [ -z "$CK_FORK" ]; then
CK_FORK=yes
else
export CK_FORK=$CK_FORK
fi
# Run make check and save the result
make check -C $SLURM_BUILD_DIR/testsuite/slurm_unit --no-print-directory
rc=$?
# Print the log of the desired check test, or none
if [ ! -z "$SLURM_CHECK_LOG" ]; then
files=`ls $SLURM_BUILD_DIR/testsuite/slurm_unit/**/$SLURM_CHECK_LOG-test.log`
for file in $files; do
echo "==========================================================="
echo "Test Log: $file"
echo "==========================================================="
cat $file
done
fi
# Print a final failure / success message
if [ $rc != 0 ]; then
echo -ne "${RED}"
echo "==========================================================="
echo "CHECK FAILURE: $rc"
echo "==========================================================="
echo -ne "$NC"
else
echo -ne "${GREEN}"
echo "==========================================================="
echo "CHECK SUCCESS"
echo "==========================================================="
echo -ne "$NC"
fi
}
slurm-dbd()
{
$SLURM_LOCAL_DIR/sbin/slurmdbd -Dvvv $*
}
slurm-ctld()
{
$SLURM_LOCAL_DIR/sbin/slurmctld -Dvvv $*
}
slurm-d()
{
$SLURM_LOCAL_DIR/sbin/slurmd -DvvvN $*
}
slurm-tail-d()
{
sudo tail -n 300 -f $SLURM_LOCAL_DIR/var/log/slurmd-$1.log
}
if [ "$SLURM_SETUP_VER" != "" ]; then
slurm-setup
fi
audio-restart()
{
pulseaudio --kill
pulseaudio --start
}
gpi-monitor()
{
autossh imatge.upc.edu -t "ssh root@s1 -t tmux attach -t monitor"
}
gpi-tasks()
{
autossh imatge.upc.edu -t "tmux attach -t tasks"
}
gpi-calcula()
{
autossh calcula.tsc.upc.edu -p2225 -t "module load tmux; tmux attach -t calcula"
}
i2cat-ibpm()
{
# autossh ubuntu@ibpm -t "tmux attach -t ibpm"
ssh -i azure.pem [email protected]
}
epic-vim()
{
QT_SDK_GCC_DIR=/opt/Qt/5.14.1/gcc_64 vim --servername epic
}
# ssh launchers
slurm-snowflake()
{
ssh -p 22253 [email protected] -t ssh snowflake $*
}
slurm-knl2()
{
ssh -p 22253 [email protected] -t ssh knl2
}
agil-rdesktop()
{
rdesktop -u "Albert Gil" -e -E -N -g 1920x1080 -D -z $*
}