Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
diaspora
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
diasporg
diaspora
Commits
9723e283
Unverified
Commit
9723e283
authored
Nov 02, 2018
by
Benjamin Neff
Committed by
Dennis Schubert
Nov 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use sudo for docker if socket is not writable
closes #7921
parent
3c55a425
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
25 deletions
+35
-25
script/diaspora-dev
script/diaspora-dev
+35
-25
No files found.
script/diaspora-dev
View file @
9723e283
...
...
@@ -158,6 +158,16 @@ print_usage_full() {
# ----- Helper functions -----
dia_docker_compose
()
{
# Check permissions of docker socket and use sudo if needed
if
[
-r
"/var/run/docker.sock"
]
&&
[
-w
"/var/run/docker.sock"
]
;
then
docker-compose
"
$@
"
else
echo
"Attention: Docker socket not writable, using sudo for the docker command. You might be asked for your password now."
>
&2
sudo
-E
docker-compose
"
$@
"
fi
}
dia_fetch_upstream
()
{
# Add and fetch upstream develop branch
if
!
git remote show |
grep
-q
'^upstream$'
;
then
...
...
@@ -181,12 +191,12 @@ exit_if_unconfigured() {
dia_is_running
()
{
# Check if diaspora container is running
d
ocker-
compose ps
--services
--filter
status
=
running |
grep
-qx
'diaspora'
d
ia_docker_
compose ps
--services
--filter
status
=
running |
grep
-qx
'diaspora'
}
dia_is_db_running
()
{
# Check if db container is running
d
ocker-
compose ps
--services
--filter
status
=
running |
grep
-qx
$DIASPORA_DOCKER_DB
d
ia_docker_
compose ps
--services
--filter
status
=
running |
grep
-qx
$DIASPORA_DOCKER_DB
}
dia_get_db
()
{
...
...
@@ -199,14 +209,14 @@ dia_get_db() {
dia_build
()
{
if
[
$#
-gt
0
]
&&
[
"
$1
"
==
"--no-cache"
]
;
then
nocache
=
"--no-cache"
;
fi
# Build the diaspora Docker container (diaspora:dev-latest)
d
ocker-
compose build
$nocache
diaspora
d
ia_docker_
compose build
$nocache
diaspora
}
dia_bundle
()
{
# Run bundle in order to install all gems into $DIASPORA_ROOT
# Do not start database, not required and sometimes not yet configured
echo
"Installing gems via bundler ..."
d
ocker-
compose run
\
d
ia_docker_
compose run
\
--rm
\
--no-deps
$1
\
-e
DIA_NODB
=
1
\
...
...
@@ -223,7 +233,7 @@ dia_clean() {
;;
esac
done
d
ocker-
compose down
-v
d
ia_docker_
compose down
-v
if
[
!
-z
$dia_config_delete
]
;
then
rm
"
$DIASPORA_CONFIG_DIA
"
"
$DIASPORA_CONFIG_DB
"
fi
...
...
@@ -284,7 +294,7 @@ dia_config() {
dia_cucumber
()
{
# Run cucumber tests
if
[
"
$1
"
==
"-d"
]
;
then
detach
=
"-d"
;
shift
;
fi
d
ocker-
compose run
\
d
ia_docker_
compose run
\
--rm
$detach
\
diaspora
\
bin/cucumber
"
$@
"
...
...
@@ -296,21 +306,21 @@ dia_exec() {
if
[
"
$1
"
==
"-d"
]
;
then
detach
=
"-d"
;
shift
;
fi
if
dia_is_running
;
then
# Use a running container
d
ocker-
compose
exec
$detach
diaspora /exec-entrypoint.sh
"
$@
"
d
ia_docker_
compose
exec
$detach
diaspora /exec-entrypoint.sh
"
$@
"
else
if
!
dia_is_db_running
;
then
not_running
=
1
;
fi
# Start a new container
echo
"No running instance found, starting new one for command execution ..."
d
ocker-
compose run
--rm
$detach
--service-ports
diaspora
"
$@
"
d
ia_docker_
compose run
--rm
$detach
--service-ports
diaspora
"
$@
"
if
[
!
-z
$not_running
]
;
then
d
ocker-
compose stop
$DIASPORA_DOCKER_DB
d
ia_docker_
compose stop
$DIASPORA_DOCKER_DB
fi
fi
}
dia_jasmine
()
{
# Run jasmine tests
d
ocker-
compose run
\
d
ia_docker_
compose run
\
--rm
$1
\
-e
RAILS_ENV
=
test
\
diaspora
\
...
...
@@ -327,14 +337,14 @@ dia_logs() {
;;
esac
done
d
ocker-
compose logs
-f
--tail
=
100
$dia_follow
d
ia_docker_
compose logs
-f
--tail
=
100
$dia_follow
}
dia_migrate
()
{
# Run migrations if configured
echo
"Creating and/or migrating database ..."
exit_if_unconfigured
d
ocker-
compose run
\
d
ia_docker_
compose run
\
--rm
$1
\
diaspora
\
bin/rake db:create db:migrate
...
...
@@ -348,7 +358,7 @@ dia_pronto() {
dia_fetch_upstream
fi
cd
-
>
/dev/null
d
ocker-
compose run
\
d
ia_docker_
compose run
\
--rm
\
--no-deps
\
diaspora
\
...
...
@@ -366,11 +376,11 @@ dia_restart() {
done
if
dia_is_running
;
then
if
[
-z
$dia_restart_full
]
;
then
d
ocker-
compose
exec
\
d
ia_docker_
compose
exec
\
diaspora
\
bin/eye restart diaspora
else
d
ocker-
compose restart
d
ia_docker_
compose restart
fi
else
dia_start
...
...
@@ -384,19 +394,20 @@ dia_rspec() {
# Assumption: If (and only if) the tested file is not available, assets need be regenerated
[
-f
"
$DIASPORA_ROOT
"
/public/404.html
]
&&
assets
=
"assets:generate_error_pages"
# Prepare database (and assets if necessary)
d
ocker-
compose run
\
d
ia_docker_
compose run
\
--rm
\
-e
RAILS_ENV
=
test
\
diaspora
\
bin/rake db:create db:migrate
$assets
# Run tests
d
ocker-
compose run
\
d
ia_docker_
compose run
\
--rm
\
diaspora
\
bin/rspec
"
$@
"
}
dia_setup
()
{
# Prepare the entire environment for development
for
i
in
"
$@
"
;
do
case
"
$i
"
in
--force
)
...
...
@@ -408,7 +419,6 @@ dia_setup() {
;;
esac
done
# Prepare the entire environment for development
(
set
-e
dia_build
$build
...
...
@@ -418,15 +428,15 @@ dia_setup() {
dia_setup_tests
$setup_tests
)
# stop db afterwards as it is not needed while dia is not running
d
ocker-
compose stop
$DIASPORA_DOCKER_DB
d
ia_docker_
compose stop
$DIASPORA_DOCKER_DB
}
dia_setup_tests
()
{
# Prepare all possible tests
# stop db if it was not running before
echo
"Setting up environment for tests ..."
if
!
dia_is_db_running
;
then
stopdb
=
"d
ocker-
compose stop
$DIASPORA_DOCKER_DB
"
;
fi
d
ocker-
compose run
\
if
!
dia_is_db_running
;
then
stopdb
=
"d
ia_docker_
compose stop
$DIASPORA_DOCKER_DB
"
;
fi
d
ia_docker_
compose run
\
--rm
\
-e
RAILS_ENV
=
test
\
diaspora
\
...
...
@@ -442,19 +452,19 @@ dia_start() {
else
options
=
$1
fi
d
ocker-
compose up
$options
diaspora
d
ia_docker_
compose up
$options
diaspora
}
dia_status
()
{
# Print running containers and current images
d
ocker-
compose ps
d
ia_docker_
compose ps
echo
d
ocker-
compose images
d
ia_docker_
compose images
}
dia_stop
()
{
# Stop all containers
d
ocker-
compose stop
d
ia_docker_
compose stop
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment