-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose run function; Cleanup logging;
- Loading branch information
Showing
7 changed files
with
131 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
import createSshConnection from './utils/createSshConnection.js'; | ||
|
||
export { copy } from './tasks/copy.js'; | ||
export { enforceSshPublicKeyOnly } from './tasks/enforceSshPublicKeyOnly.js'; | ||
export { syncUsers } from './tasks/syncUsers.js'; | ||
export { updateDebian } from './tasks/updateDebian.js'; | ||
|
||
export { createSshConnection } from './utils/createSshConnection.js'; | ||
|
||
export async function run (servers) { | ||
for (const server of servers) { | ||
const connection = await createSshConnection({ | ||
ip: server.host, | ||
username: server.username, | ||
password: server.password, | ||
port: server.port, | ||
otpSecret: server.otpSecret, | ||
privateKey: server.privateKey | ||
}); | ||
|
||
for (const task of server.tasks) { | ||
await task.handler(connection); | ||
} | ||
|
||
connection.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import kleur from "kleur"; | ||
import { sshCopyFile } from "../utils/sshCopyFile.js"; | ||
|
||
export const copy = (source, destination, options) => async (connection) => { | ||
console.log(kleur.magenta('tsk:'), 'copy'); | ||
return sshCopyFile(connection, source, destination, options); | ||
}; | ||
export const copy = (source, destination, options) => ({ | ||
name: 'Copy', | ||
handler: async (connection) => { | ||
return sshCopyFile(connection, source, destination, options); | ||
} | ||
}); | ||
|
||
export default copy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import kleur from "kleur"; | ||
|
||
export const updateDebian = () => async (connection) => { | ||
console.log(kleur.magenta('tsk:'), 'updateDebian'); | ||
await connection.exec(` | ||
sudo apt-get -qy update | ||
sudo apt-get -qy upgrade | ||
sudo apt-get -qy autoremove | ||
`); | ||
}; | ||
export const updateDebian = () => ({ | ||
name: 'Update Debian', | ||
handler: async (connection) => { | ||
await connection.exec(` | ||
sudo apt-get -qy update | ||
sudo apt-get -qy upgrade | ||
sudo apt-get -qy autoremove | ||
`); | ||
} | ||
}); | ||
|
||
export default updateDebian; |