-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add scripts/install/auto-install.sh #824
Changes from 9 commits
9917cf4
d4ebdf8
8f17431
b5a9f2d
7cdc970
52dd23a
41cdf85
c16558b
d11f8fe
4031a81
9795b1e
9efc869
ef1cd69
3f60c0d
9627824
13c2c91
452d8bc
de5a509
ec2d089
1abd4e1
e1ed9cf
32f3095
c4188fa
8523041
c5431c6
35e8bdb
e8cdc37
c84fdda
f452e32
42c290d
1b14b96
db22f84
a0e2ad2
e2753a1
02c3d1e
8118344
96350bd
7d7b52d
3955798
433471f
732a2ca
0f77dc6
f742e52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,147 @@ | ||||||
#!/bin/bash | ||||||
# auto-install.sh installs git if it isn't installed, then clones POCS and | ||||||
# installs its dependencies. | ||||||
# | ||||||
# To fetch this from github and execute it immediately, run one of these two | ||||||
# commands in a bash shell, the first if you have wget installed, the second | ||||||
# if you have curl installed: | ||||||
# | ||||||
# 1a) wget -O - https://raw.githubusercontent.com/panoptes/POCS/develop/scripts/install/auto-install.sh | bash | ||||||
# 1b) bash <(wget -O - https://raw.githubusercontent.com/panoptes/POCS/develop/scripts/install/auto-install.sh) | ||||||
# | ||||||
# 2) bash <(curl -s https://raw.githubusercontent.com/panoptes/POCS/develop/scripts/install/auto-install.sh) | ||||||
# | ||||||
# To determine whether you have these commands install, type these commands: | ||||||
# | ||||||
# which wget | ||||||
# which curl | ||||||
|
||||||
################################################################################ | ||||||
# Env vars used for debugging of this script; these allow you to point to your | ||||||
# fork of POCS on github, so that you can download your fork instead of the | ||||||
# primary repo. There is no support for doing the same with PAWS. | ||||||
|
||||||
[[ -z "${POCS_GITHUB_USER}" ]] && export POCS_GITHUB_USER="panoptes" | ||||||
[[ -z "${POCS_GIT_URL}" ]] && export POCS_GIT_URL="https://github.com/${POCS_GITHUB_USER}/POCS.git" | ||||||
[[ -z "${POCS_BRANCH}" ]] && export POCS_BRANCH="develop" | ||||||
|
||||||
################################################################################ | ||||||
# Functions COPIED from install-helper-functions.sh | ||||||
# Print the disk location of the first arg. | ||||||
function safe_which() { | ||||||
type -p "${1}" || /bin/true | ||||||
} | ||||||
|
||||||
# Print a separator bar of # characters. | ||||||
function echo_bar() { | ||||||
local terminal_width | ||||||
if [ -n "${TERM}" ] && [ -t 0 ] ; then | ||||||
if [[ -n "$(which resize)" ]] ; then | ||||||
terminal_width="$(resize 2>/dev/null | grep COLUMNS= | cut -d= -f2)" | ||||||
elif [[ -n "$(which stty)" ]] ; then | ||||||
terminal_width="$(stty size 2>/dev/null | cut '-d ' -f2)" | ||||||
fi | ||||||
fi | ||||||
printf "%${terminal_width:-80}s\n" | tr ' ' '#' | ||||||
} | ||||||
################################################################################ | ||||||
|
||||||
function do_sudo() { | ||||||
if [ "$(id -u -n)" == "root" ] ; then | ||||||
echo "Running ${*}" | ||||||
"$@" | ||||||
else | ||||||
echo "Running sudo ${*}; you may be prompted for your password." | ||||||
(set -x ; sudo "$@") | ||||||
fi | ||||||
} | ||||||
|
||||||
function clone_or_update() { | ||||||
local -r REPO_DIR="${1}" | ||||||
local -r REPO_URL="${2}" | ||||||
local -r BRANCH="${3}" | ||||||
|
||||||
echo_bar | ||||||
|
||||||
if [ ! -d "${REPO_DIR}/.git" ] | ||||||
then | ||||||
if [ -d "${REPO_DIR}" ] | ||||||
then | ||||||
echo 2> " | ||||||
The directory (${REPO_DIR}) already exists, but doesn't appear | ||||||
to be a valid git repository. Please remove it (or move it out | ||||||
of the way) and re-run this script. | ||||||
" | ||||||
exit 1 | ||||||
fi | ||||||
echo " | ||||||
Cloning ${REPO_URL} into ${REPO_DIR} | ||||||
" | ||||||
(set -x ; git clone "${REPO_URL}" "${REPO_DIR}") | ||||||
cd "${REPO_DIR}" | ||||||
git checkout "${BRANCH}" | ||||||
jamessynge marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
else | ||||||
echo " | ||||||
Pulling the latest software into the worktree at ${REPO_DIR} | ||||||
jamessynge marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
" | ||||||
cd "${REPO_DIR}" | ||||||
git fetch --all | ||||||
git checkout "${BRANCH}" | ||||||
git pull | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If they have already set up the repo they might have I think if the dir is there and a repo we just do nothing other than maybe print a message reminding them to update. Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, clearly if there are already files staged then we need to avoid messing with the repo. I'll adjust the script to stop if there is a POCS or PAWS repo. |
||||||
fi | ||||||
} | ||||||
|
||||||
# Exit immediately if a command fails: | ||||||
set -e | ||||||
|
||||||
# COPIED from default-env-vars.sh | ||||||
[[ -z "${PANUSER}" ]] && export PANUSER="panoptes" # Default user | ||||||
[[ -z "${PANDIR}" ]] && export PANDIR="/var/panoptes" # Main Dir | ||||||
[[ -z "${PANLOG}" ]] && export PANLOG="${PANDIR}/logs" # Log files | ||||||
[[ -z "${POCS}" ]] && export POCS="${PANDIR}/POCS" # Main Observatory Control | ||||||
[[ -z "${PAWS}" ]] && export PAWS="${PANDIR}/PAWS" # Web Interface | ||||||
|
||||||
if [[ "$(whoami)" != "${PANUSER}" ]] ; then | ||||||
echo >2 "Please run this script as ${PANUSER}, not as $(whoami)" | ||||||
jamessynge marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
exit 1 | ||||||
fi | ||||||
|
||||||
# Let's assume we'll need to run apt-get install, so first run apt-get update | ||||||
# which will refresh caches used during apt-get install. | ||||||
echo_bar | ||||||
do_sudo apt-get update | ||||||
|
||||||
if [ ! -x "$(safe_which git)" ] | ||||||
then | ||||||
echo_bar | ||||||
echo " | ||||||
git is not installed, so installing it... | ||||||
" | ||||||
do_sudo apt-get install -y git | ||||||
fi | ||||||
|
||||||
echo_bar | ||||||
echo " | ||||||
Ensuring that ${PANDIR} exists | ||||||
jamessynge marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
" | ||||||
if [ ! -d "${PANDIR}" ] | ||||||
then | ||||||
do_sudo mkdir -p "${PANDIR}" | ||||||
fi | ||||||
|
||||||
echo_bar | ||||||
echo " | ||||||
Ensuring that ${PANDIR} is owned by user ${PANUSER} | ||||||
jamessynge marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
" | ||||||
do_sudo chown "${PANUSER}" "${PANDIR}" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I added the recursive option because I was thinking the subdirectories existed at this point but it looks like not but the option shouldn't hurt. Also not sure if wanted the group changed or not, I usually default to changing both. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried that a while ago, even had it in this code earlier today, but then I remembered that it was really very slow if the full tree was already there. I can reconsider/retest if you like. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. It seems like there shouldn't be that many files in the tree. But okay not doing it. That means are assuming if it already exists then the user has already set their permissions accordingly, which I think is fine. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added it, and it worked fine. I now recall that the slow case was inside of docker. |
||||||
|
||||||
clone_or_update "${POCS}" "${POCS_GIT_URL}" "${POCS_BRANCH}" | ||||||
clone_or_update "${PAWS}" "https://github.com/panoptes/PAWS.git" "develop" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could obviously add the ability to clone a forked version of PAWS but I suppose not entirely necessary at this point. Can leave until we overhaul PAWS, which needs to happen soonish. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly. |
||||||
|
||||||
echo_bar | ||||||
echo " | ||||||
Executing ${POCS}/scripts/install/install-dependencies.sh, which will | ||||||
install the tools needed to run POCS. | ||||||
" | ||||||
|
||||||
${POCS}/scripts/install/install-dependencies.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -574,7 +574,10 @@ function maybe_install_conda() { | |
function get_installed_astrometry_version() { | ||
local -r solve_field="${ASTROMETRY_DIR}/bin/solve-field" | ||
if [[ -x "${solve_field}" ]] ; then | ||
"${solve_field}" --help|(grep -E '^Revision [0-9.]+,' || /bin/true)|cut -c10-|cut -d, -f1 | ||
("${solve_field}" --help \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, just checking version number. |
||
| (grep -E --only-matching '^Revision [0-9.]+' || /bin/true) \ | ||
| cut -c10- \ | ||
| cut -d, -f1) | ||
fi | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine, but I have been thinking lately that we should go back to pushing release versions to
master
and having non-developer units always pull frommaster
. Mostly the onus here would be on me to actually be good about making releases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that might be a good idea to use master that way. I.e. on rare occasions, and after testing on multiple units, we declare a new version that non-developers should use.