Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
argotk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
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
argo
argotk
Commits
42e018b0
Commit
42e018b0
authored
Feb 16, 2019
by
Valentin Reis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactor.
parent
a2eda2ec
Pipeline
#5326
passed with stage
in 2 minutes and 28 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
46 deletions
+19
-46
src/Argo/Stack.hs
src/Argo/Stack.hs
+18
-45
src/Argo/Utils.hs
src/Argo/Utils.hs
+1
-1
No files found.
src/Argo/Stack.hs
View file @
42e018b0
...
...
@@ -33,49 +33,31 @@ import Control.Monad as CM
import
Data.Maybe
import
Control.Foldl
as
Fold
import
Text.Show.Pretty
import
System.Environment
cleanLeftovers
::
WorkingDirectory
->
Shell
()
--TODO
cleanLeftovers
(
WorkingDirectory
wd
)
=
do
printInfo
"Cleaning working(output) directory."
cleanLog
wd
printInfo
"Cleaning sockets."
CM
.
mapM_
cleanSocket
[
"/tmp/nrm-downstream-in"
,
"/tmp/nrm-upstream-in"
,
"/tmp/nrm-downstream-event"
]
checkFsAttributes
::
FilePath
->
Shell
()
checkFsAttributes
workingDirectory
=
do
let
dir
=
case
toText
workingDirectory
of
Left
di
->
di
Right
di
->
di
let
findmnt
=
inproc
"findmnt"
[
"-T"
,
dir
,
"-o"
,
"OPTIONS"
]
empty
b
<-
liftIO
$
Turtle
.
Shell
.
fold
(
grep
(
has
"nosuid"
)
findmnt
)
Fold
.
length
when
(
b
>
0
)
$
dieRed
$
format
(
"The output directory, "
%
fp
%
", must not mounted with
\"
nosuid
\"
"
)
workingDirectory
CM
.
mapM_
cleanSocket
[
"/tmp/nrm-downstream-in"
,
"/tmp/nrm-downstream-event"
,
"/tmp/nrm-upstream-in"
,
"/tmp/nrm-upstream-event"
]
printInfo
"Cleaning output directory."
void
$
shell
(
format
(
"rm -rf "
%
fp
)
wd
)
Turtle
.
empty
prepareDaemon
::
StdOutLog
->
StdErrLog
->
Maybe
TestText
->
Shell
Instrumentation
prepareDaemon
out
stdErr
test
=
do
_
<-
myWhich
"daemon"
confPath
<-
myWhich
"argo_nodeos_config"
let
confPath'
=
"./argo_nodeos_config"
cp
confPath
confPath'
printInfo
$
format
(
"Copied the configurator to "
%
fp
)
confPath'
printInfo
$
format
"Trying to sudo chown and chmod argo_nodeos_config"
sudoPath
<-
liftIO
$
pack
<$>
getEnv
"SUDO"
verboseShell
(
format
(
s
%
" chown root:root "
%
fp
)
sudoPath
confPath'
)
empty
>>=
\
case
ExitSuccess
->
printInfo
"Chowned argo_nodeos_config to root:root."
ExitFailure
n
->
die
(
"Failed to set argo_nodeos_config permissions "
<>
repr
n
)
verboseShell
(
format
(
s
%
" chmod u+sw "
%
fp
)
sudoPath
confPath'
)
empty
>>=
\
case
ExitSuccess
->
printInfo
"Set the suid bit."
ExitFailure
n
->
die
(
"Setting suid bit failed with exit code "
<>
repr
n
)
_
<-
myWhich
"daemon"
let
confPath'
=
"/tmp/argo_nodeos_config"
cleanContainers
confPath'
1
2
export
"ARGO_NODEOS_CONFIG"
(
format
fp
confPath'
)
return
$
Instrumentation
(
P
.
proc
"daemon"
[]
)
out
stdErr
test
return
$
Instrumentation
(
P
.
proc
"daemon"
[
"--nrm_log"
,
"./nrm_log"
])
out
stdErr
test
where
nodeOsFailure
n
=
do
printError
(
"argo_nodeos_config failed with exit code :"
<>
repr
n
)
...
...
@@ -198,18 +180,9 @@ runStack :: StackArgs -> Shell StackOutput
runStack
sa
@
StackArgs
{
..
}
=
do
when
(
verbosity
==
Verbose
)
$
liftIO
$
pPrint
sa
CM
.
mapM_
cleanSocket
[
"/tmp/nrm-downstream-in"
,
"/tmp/nrm-downstream-event"
,
"/tmp/nrm-upstream-in"
,
"/tmp/nrm-upstream-event"
]
let
(
WorkingDirectory
wd
)
=
workingDirectory
_
<-
Turtle
.
shell
(
format
(
"rm -rf "
%
fp
)
wd
)
Turtle
.
empty
mktree
wd
checkFsAttributes
wd
cd
wd
cleanLeftovers
workingDirectory
CM
.
mapM_
(
$
(
coerce
workingDirectory
::
FilePath
))
[
mktree
,
cd
]
iDaemon
<-
case
daemon
of
DontRun
->
return
Nothing
...
...
src/Argo/Utils.hs
View file @
42e018b0
...
...
@@ -100,7 +100,7 @@ verboseShell' :: Text -> Shell Line -> Shell (ExitCode, Text, Text)
verboseShell'
command
i
=
printCommand
command
>>
shellStrictWithErr
command
i
cleanSocket
::
FilePath
->
Shell
()
cleanSocket
=
sudoRemoveFile
print
Error
"socket"
cleanSocket
=
sudoRemoveFile
print
Warning
"socket"
cleanLog
::
FilePath
->
Shell
()
cleanLog
=
sudoRemoveFile
printWarning
"log folder"
...
...
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