feat: make start script work in an unintened cli
This commit is contained in:
parent
ee41a9701a
commit
a594e63906
4 changed files with 34 additions and 12 deletions
|
@ -52,9 +52,16 @@ export class SystemExecutors {
|
|||
};
|
||||
|
||||
private ensureFilePermissions = async (rootFolderHost: string, logSudoRequest = true) => {
|
||||
if (logSudoRequest) {
|
||||
console.log('\nTipi is asking for your password\nin order to ensure permissions\non copied files and folders\n');
|
||||
// if we are running as root, we don't need to change permissions
|
||||
if (process.getuid && process.getuid() === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (logSudoRequest) {
|
||||
const logger = new TerminalSpinner('');
|
||||
logger.log('Tipi needs to change permissions on some files and folders and will ask for your password.');
|
||||
}
|
||||
|
||||
const filesAndFolders = [
|
||||
path.join(rootFolderHost, 'apps'),
|
||||
path.join(rootFolderHost, 'logs'),
|
||||
|
@ -134,10 +141,12 @@ export class SystemExecutors {
|
|||
* This method will start Tipi.
|
||||
* It will copy the system files, generate the system env file, pull the images and start the containers.
|
||||
*/
|
||||
public start = async () => {
|
||||
public start = async (permissions = true) => {
|
||||
const spinner = new TerminalSpinner('Starting Tipi...');
|
||||
try {
|
||||
if (permissions) {
|
||||
await this.ensureFilePermissions(this.rootFolder);
|
||||
}
|
||||
|
||||
spinner.start();
|
||||
spinner.setMessage('Copying system files...');
|
||||
|
@ -145,7 +154,9 @@ export class SystemExecutors {
|
|||
|
||||
spinner.done('System files copied');
|
||||
|
||||
if (permissions) {
|
||||
await this.ensureFilePermissions(this.rootFolder, false);
|
||||
}
|
||||
|
||||
spinner.setMessage('Generating system env file...');
|
||||
spinner.start();
|
||||
|
@ -331,7 +342,7 @@ export class SystemExecutors {
|
|||
// eslint-disable-next-line no-promise-executor-return
|
||||
await new Promise((resolve) => setTimeout(resolve, 3000));
|
||||
|
||||
const childProcess = spawn('./runtipi-cli', [process.argv[1] as string, 'start']);
|
||||
const childProcess = spawn('./runtipi-cli', [process.argv[1] as string, 'start', '--no-permissions']);
|
||||
|
||||
childProcess.stdout.on('data', (data) => {
|
||||
process.stdout.write(data);
|
||||
|
|
|
@ -20,9 +20,10 @@ const main = async () => {
|
|||
program
|
||||
.command('start')
|
||||
.description('Start tipi')
|
||||
.action(async () => {
|
||||
.option('--no-permissions', 'Skip permissions check')
|
||||
.action(async (options) => {
|
||||
const systemExecutors = new SystemExecutors();
|
||||
await systemExecutors.start();
|
||||
await systemExecutors.start(options.permissions);
|
||||
});
|
||||
|
||||
program
|
||||
|
|
|
@ -52,4 +52,10 @@ export class TerminalSpinner {
|
|||
|
||||
logUpdate.done();
|
||||
}
|
||||
|
||||
log(message: string) {
|
||||
logUpdate(message);
|
||||
|
||||
logUpdate.done();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -186,10 +186,14 @@ curl --location "$URL" -o ./runtipi-cli
|
|||
chmod +x ./runtipi-cli
|
||||
|
||||
# Check if user is in docker group
|
||||
if ! groups | grep -q docker; then
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if ! groups | grep -q docker; then
|
||||
echo ""
|
||||
echo "User is not in docker group. Please make sure your user is allowed to run docker commands and restart the script."
|
||||
echo "See https://docs.docker.com/engine/install/linux-postinstall/ for more information."
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
./runtipi-cli start
|
||||
|
|
Loading…
Reference in a new issue