os.yaml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. tasks:
  2. # Generic tasks
  3. bash:
  4. desc: Interactive prompt
  5. run: "bash"
  6. create-dir:
  7. desc: Add a new directory
  8. run: "mkdir -p {path}"
  9. symlink:
  10. desc: Create symlink
  11. run: |
  12. if test ! -e {to}
  13. then ln -s {from} {to}
  14. fi
  15. mount:
  16. run: mount | grep ' {path} ' &> /dev/null || mount {path}
  17. move:
  18. desc: Move a file or directory
  19. run: |
  20. if test ! -e {to}
  21. then mv {from} {to}
  22. fi
  23. copy:
  24. desc: Copy a file or directory
  25. run: |
  26. if test -f {from}
  27. then cp {from} {to}
  28. else cp -Tr {from} {to}
  29. fi
  30. remove:
  31. desc: Remove (-r) path
  32. run: "rm -r {path}"
  33. chown:
  34. desc: Chown a file or directory
  35. run: "chown -R {user}. {path}"
  36. chmod:
  37. desc: Chmod a file or directory
  38. run: "chmod -R {mode} {path}"
  39. apt-install:
  40. desc: Run apt install
  41. run: apt update && apt install -y {packages}
  42. sudo: true
  43. systemctl:
  44. desc: Call systemctl
  45. run: systemctl {action} {service}
  46. sudo: true
  47. send:
  48. desc: Send a file or a directory
  49. send: "{send}"
  50. to: "{to}"
  51. sudo-send:
  52. desc: Combine send & sudo-move
  53. multi:
  54. - task: send
  55. env:
  56. to: "/tmp/{tmppath}"
  57. - task: copy
  58. sudo: true
  59. env:
  60. from: "/tmp/{tmppath}"
  61. - task: remove
  62. env:
  63. path: "/tmp/{tmppath}"
  64. parted:
  65. desc: Create primary partition && mkfs
  66. sudo: true
  67. run: |
  68. if test ! -e {device}1
  69. then
  70. parted {device} -a optimal --script mklabel gpt mkpart primary 0% 100%
  71. sleep 1
  72. mkfs -t ext4 {device}1
  73. fi
  74. append-line:
  75. desc: Append line to file
  76. run: >-
  77. grep {guard} {file} &> /dev/null
  78. || echo {line} >> {file}
  79. add-user:
  80. desc: Create a new user
  81. run: id {user} || sudo adduser {user} --disabled-login --gecos ""
  82. add-group:
  83. desc: Add group to user
  84. run: usermod -a -G {user} {group}
  85. wget:
  86. desc: Download a file
  87. run: test -f {file} || wget -O {file} {url}
  88. unzip:
  89. desc: Unzip a zip file
  90. run: test -d {dir} || unzip {file} -d {dir}
  91. patch:
  92. desc: Patch a file with a specific local diff file
  93. run: |
  94. patch --ignore-whitespace --reject-file=/dev/null -uN {file} << EOF
  95. {diff_string}
  96. EOF
  97. send-rmcr:
  98. desc: Send a file but remove its carriage returns before.
  99. multi:
  100. - task: send
  101. - run: "tr -d '\r' < {to} > {to}-tmp"
  102. - task: move
  103. env:
  104. from: "{to}-tmp"
  105. sudo-send-rmcr:
  106. desc: Combine send & sudo-move, and remove carriage returns
  107. multi:
  108. - task: send
  109. env:
  110. to: "/tmp/{tmppath}"
  111. - task: rmcr
  112. env:
  113. from: "/tmp/{tmppath}"
  114. sudo: true
  115. - task: remove
  116. env:
  117. path: "/tmp/{tmppath}"
  118. rmcr:
  119. desc: remove carriage returns and move file
  120. run: "tr -d '\r' < {from} | tee {to} > /dev/null"
  121. unlink:
  122. desc: remove a symlink
  123. run: "test -L {path} && unlink {path}"