-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure
executable file
·88 lines (71 loc) · 2.36 KB
/
configure
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
#!/usr/bin/env bash
source ~/.profile
# get directory where this file is in and set as directory
JMB="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $JMB
echo "i config starting"
echo "i jmb is here: $JMB"
export HERE=$JMB/bin
if [[ ${JMB} == '' ]]
then
echo "i exporting JMB"
echo "export JMB=$HERE" >> ~/.profile
export JMB=$HERE
fi
if [[ $(echo "$PATH" | grep "$JMB" -F) == '' ]]
then
echo "i updating PATH"
echo "export PATH="$JMB${PATH:+:${PATH}}"" >> ~/.profile
export PATH="$JMB${PATH:+:${PATH}}"
fi
echo "i making bin/ executable"
chmod +x bin/*
echo "i running dos2unix"
dos2unix bin/dos2unix-dir
./bin/dos2unix-dir bin
echo "i installing pak and scribe"
R_LIB_PAK=$(Rscript --vanilla \
-e "cat(file.path(dirname(.Library.site[1]), 'pak-library'))"
)
R --vanilla <<EOF
lib_pak <- "$R_LIB_PAK"
stopifnot(nzchar(lib_pak))
dir.create(lib_pak, recursive = TRUE, showWarnings = FALSE)
Sys.chmod(lib_pak, "777")
if (!requireNamespace("pak", lib.loc = lib_pak, quietly = TRUE)) {
utils::install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/", lib = lib_pak)
}
EOF
echo "i installing pack and scribe again"
./bin/pak-install source --lib-path $R_LIB_PAK
# TODO replace SCRIBE_VERSION with cran version
SCRIBE_VERSION=$(Rscript --vanilla \
-e "lines <- readLines('https://cran.r-project.org/web/packages/scribe/index.html')" \
-e "version <- lines[grep('Version', lines) + 1L]" \
-e "m <- gregexpr('[0-9]?[.][0-9]?([.][0-9]?)?', version)" \
-e "cat(as.character(numeric_version(regmatches(version, m)[[1]])))"
)
# update line in bin/pak
sed -i "s/SCRIBE_VERSION <- .*/SCRIBE_VERSION <- \"$SCRIBE_VERSION\"/g" bin/pak
# add symbolic link on linux and when in sudo
if [[ $(uname) == 'Linux' ]]
then
# warn when not root
if [[ $(whoami) != 'root' ]]
then
echo "w not root, will not add symbolic link"
else
echo "i adding symbolic link"
mkdir -p /usr/local/jmb/bin
sudo ln -s -f $JMB/bin/ /usr/local/jmb || true
sudo chmod +x -R /usr/local/jmb/bin
# check secure_path
if [[ $(sudo cat /etc/sudoers | grep secure_path | grep -c $JMB/bin) == 0 ]]
then
echo "i adding jmb/bin to secure_path"
sudo sed -i.bak '/secure_path/ s|$|:'$JMB'/bin|' /etc/sudoers
fi
fi
fi
echo "i done"
echo "i best to restart console"