🎉 Initial commit
This commit is contained in:
commit
dac75d025a
7 changed files with 441 additions and 0 deletions
64
README.md
Executable file
64
README.md
Executable file
|
@ -0,0 +1,64 @@
|
|||
# FAKE // OS
|
||||
FAKE//OS system utilities and scripts.
|
||||
|
||||
# Philosophy
|
||||
1. **Standardised:** Functions should work consistently across multiple Operating System Distributions.
|
||||
2. **Repeatable:** Functions should be able to re-run (for upgrade purposes) without destroying already modified system configurations.
|
||||
3. **Modularity:** Functions should be simple and modular for easy additions and modifications.
|
||||
3. **Error Handling:** Functions should have good error handling for use in automated scripts.
|
||||
|
||||
# Supported Operating Systems
|
||||
FAKE//OS aims to be system agnostic, and provide a consistent set of functions (especially for scripting) across a variety of Linux distributions, which otherwise don't play well together. Currently supported distributions include:
|
||||
- Arch Linux _[bash + systemd + pacman/paru]_
|
||||
- Artix Linux _[bash + openrc + pacman/paru]_
|
||||
- Alpine Linux _[ash + openrc + apk]_
|
||||
- Debian Linux _[bash/dash + systemd + apt]_
|
||||
|
||||
# Basic Ussage
|
||||
``` bash
|
||||
FAKE//OS Package and System Manager
|
||||
-----------------------------------
|
||||
usage: fake <command> <arguments>
|
||||
|
||||
Package management commands:
|
||||
install Install new software packages
|
||||
update Update installed software packages
|
||||
remove Remove/Uninstall software packages
|
||||
search Search repository for software packages
|
||||
|
||||
Init/System management commands
|
||||
start Start system daemons
|
||||
stop Stop system daemons
|
||||
restart Restart system daemons
|
||||
enable Add system daemons to default startup PID
|
||||
disable Remove system daemons from default startup PID
|
||||
flush Clear syste caches
|
||||
|
||||
FAKE//OS commands:
|
||||
upgrade Upgrade FAKE//OS to latest git version
|
||||
help Display this help screen
|
||||
```
|
||||
|
||||
# Install FAKE // OS
|
||||
### Automatic Install
|
||||
Copy and paste the following into you're command-line terminal:
|
||||
|
||||
``` bash
|
||||
curl https://fake.onl/fake-os.sh | sh
|
||||
```
|
||||
|
||||
### Manual Install
|
||||
For manual installation and access to the source-code run the following commands:
|
||||
|
||||
``` bash
|
||||
git clone https://git.fake.onl/fake/fake-os.git
|
||||
cd fake-os
|
||||
./setup.sh
|
||||
```
|
||||
|
||||
### Upgrade Install
|
||||
Once installed FAKE//OS can be upgraded (install the latest version from git.fake.onl) by running the following command:
|
||||
|
||||
``` bash
|
||||
fake upgrade
|
||||
```
|
9
assets/logo.txt
Normal file
9
assets/logo.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
.^!?JJ?7^.
|
||||
^YB#GPYYYPGG?:
|
||||
.5&&J^ .~Y5!
|
||||
Y@&~ !P~
|
||||
:#@B .GP.
|
||||
P@&? !GY
|
||||
:P@@B5J?!: .7P5.
|
||||
7G&@@@@@7 :!?~
|
||||
^7JYJ7. .
|
9
assets/logo_full.txt
Normal file
9
assets/logo_full.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
..
|
||||
.:xKX0O00d, _____ _ _ _______ ____ ___ ____
|
||||
dNKc. 'od' | ___/ \ | |/ / ____| / / / / _ \/ ___|
|
||||
kWO .d, | |_ / _ \ | ' /| _| / / / | | | \___ \
|
||||
.WWc oO | _/ ___ \| . \| |___ / / / | |_| |___) |
|
||||
0WX. .kx |_|/_/ \_\_|\_\_____| /_/_/ \___/|____/
|
||||
xWWKOxo; 'xd ---------------------------------------------
|
||||
'oKWWWX' .. Fake Operating System
|
||||
..
|
7
assets/logo_text.txt
Normal file
7
assets/logo_text.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
_____ _ _ _______ ____ ___ ____
|
||||
| ___/ \ | |/ / ____| / / / / _ \/ ___|
|
||||
| |_ / _ \ | ' /| _| / / / | | | \___ \
|
||||
| _/ ___ \| . \| |___ / / / | |_| |___) |
|
||||
|_|/_/ \_\_|\_\_____| /_/_/ \___/|____/
|
||||
---------------------------------------------
|
||||
Fake Operating System setup
|
95
setup.sh
Normal file
95
setup.sh
Normal file
|
@ -0,0 +1,95 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
|
||||
# ┌──────────────┤ FAKE // OS │ Main Entrypoint ├────────────┐
|
||||
# │ │
|
||||
# │ Main entrypoint installer for FAKE // OS │
|
||||
# │ │
|
||||
# ├──────────────────────────────────────────────────────────┤
|
||||
# │ Version: 0.1 Date: 2025-05-13 │
|
||||
# │ License: GPL3+NIGGER (C) 2025 Geoff Murphy │
|
||||
# └──────────────────────────────────────────────────────────┘
|
||||
|
||||
|
||||
#--------[ Bootstrap Correct Shell ]--------#
|
||||
if [ "$SHELL" = "/bin/bash" ] && [ ! "$BASH_VERSION" ]; then
|
||||
echo "running 'dash' -> bootstrapping to 'bash'"
|
||||
curl https://fake.onl/fake-os.sh | bash
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
#--------[ Check Root ]--------#
|
||||
if [ "$EUID" -ne 0 ]; then echo "Script must be run as root..." && exit; fi
|
||||
|
||||
|
||||
#--------[ FAKE//OS Install Variables ]--------#
|
||||
export FAKE_PATH=/opt/fakeos # System location to install
|
||||
|
||||
|
||||
#--------[ FAKE//OS Splash Screen ]--------#
|
||||
clear
|
||||
echo ""
|
||||
echo " .. "
|
||||
echo " .:xKX0O00d, _____ _ _ _______ "
|
||||
echo " dNKc. 'od' | ___/ \ | |/ / ____| "
|
||||
echo " kWO .d, | |_ / _ \ | ' /| _| "
|
||||
echo ".WWc oO | _/ ___ \| . \| |___ "
|
||||
echo " 0WX. .kx |_|/_/ \_\_|\_\_____| "
|
||||
echo " xWWKOxo; 'xd ----------------------- "
|
||||
echo " 'oKWWWX' .. Operating System "
|
||||
echo " .. ~ Installer ~ "
|
||||
echo ""
|
||||
|
||||
|
||||
#--------[ FAKE//OS Check Dependencies ]--------#
|
||||
FAKE_DEP=""
|
||||
if [ ! "$(command -v git)" ]; then FAKE_DEP="$FAKE_DEP git"; fi
|
||||
if [ ! "$(command -v curl)" ]; then FAKE_DEP="$FAKE_DEP curl"; fi
|
||||
if [ ! "$(command -v figlet)" ]; then FAKE_DEP="$FAKE_DEP figlet"; fi
|
||||
if [ ! "$(command -v rsync)" ]; then FAKE_DEP="$FAKE_DEP rsync"; fi
|
||||
if [ ! "$(command -v sudo)" ]; then FAKE_DEP="$FAKE_DEP sudo"; fi
|
||||
if [ ! "$(command -v vim)" ]; then FAKE_DEP="$FAKE_DEP vim"; fi
|
||||
|
||||
|
||||
#--------[ FAKE//OS Install Dependencies ]--------#
|
||||
if [ "$FAKE_DEP" != "" ]; then
|
||||
echo "Dependancies: [ $FAKE_DEP ]"
|
||||
echo ""
|
||||
if [ "$(command -v pacman)" ]; then CMD="pacman -Syyy && pacman --noconfirm -S $FAKE_DEP"
|
||||
elif [ "$(command -v apt)" ]; then CMD="apt -y update && apt -y install $FAKE_DEP"
|
||||
elif [ "$(command -v apk)" ]; then CMD="apk update && apk add $FAKE_DEP"
|
||||
elif [ "$(command -v dnf)" ]; then CMD="dnf update && dnf -y install $FAKE_DEP"
|
||||
else CMD="echo '[ERROR] Incompatable System...'"; fi
|
||||
INDEX=1
|
||||
if ! eval "$CMD" ; then
|
||||
while ! eval "$CMD"; do
|
||||
INDEX=$(( INDEX + 1 ))
|
||||
echo "[ERROR] Retrying: Attempt $INDEX..."
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#--------[ FAKE//OS Git Clone ]--------#
|
||||
rm -rf /opt/fakeos
|
||||
mkdir -p /opt
|
||||
git clone --depth 1 https://git.fake.onl/fake/fake-os.git $FAKE_PATH
|
||||
|
||||
|
||||
#--------[ FAKE//OS Link System Tools ]--------#
|
||||
ln -sf $FAKE_PATH/src/fake_manager.sh /usr/sbin/fake
|
||||
ln -sf $FAKE_PATH/src/fake_shell.sh /etc/skel/.bashrc
|
||||
ln -sf $FAKE_PATH/src/fake_shell.sh /etc/skel/.profile
|
||||
|
||||
|
||||
#--------[ FAKE//OS Link Existing Users ]--------#
|
||||
TMP_USERS="root $(ls /home)"
|
||||
for USER in $TMP_USERS; do
|
||||
if [ "$USER" == "root" ]; then HOMEDIR="/root";
|
||||
else HOMEDIR="/home/$USER"; fi
|
||||
rm -rf $HOMEDIR/.bashrc
|
||||
rm -rf $HOMEDIR/.profile
|
||||
ln -sf $FAKE_PATH/src/fake_shell.sh $HOMEDIR/.bashrc
|
||||
ln -sf $FAKE_PATH/src/fake_shell.sh $HOMEDIR/.profile
|
||||
done
|
215
src/fake_manager.sh
Normal file
215
src/fake_manager.sh
Normal file
|
@ -0,0 +1,215 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
|
||||
#--------[ FAKE//OS Logging ]--------#
|
||||
export FAKE_LOG="/var/log/fake/fake-os.log"
|
||||
mkdir -p "$(dirname $FAKE_LOG)"
|
||||
|
||||
|
||||
#--------[ FAKE//OS System Variables ]--------#
|
||||
export FAKE_PATH=/opt/fakeos # System location
|
||||
|
||||
|
||||
#--------[ Check Root ]--------#
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
export FAKE_SUDO="sudo"
|
||||
export FAKE_BTL=""
|
||||
else
|
||||
export FAKE_SUDO=""
|
||||
export FAKE_BTL="sudo -u admin $SHELL -C"
|
||||
fi
|
||||
|
||||
|
||||
#--------[ Input Variables ]--------#
|
||||
VARS=$(echo "$@" | sed -e 's/[^ ]* *//')
|
||||
|
||||
|
||||
|
||||
# ┌───────────────────────────────────────┐
|
||||
# │ Update │
|
||||
# └───────────────────────────────────────┘
|
||||
_fake_update () {
|
||||
echo "[UPDATE] $(date)" >> $FAKE_LOG
|
||||
if [ "$(command -v paru)" ]; then CMD="$FAKE_BTL paru --noconfirm -Syyy && $FAKE_BTL paru --noconfirm -Syu"
|
||||
elif [ "$(command -v pacman)" ]; then CMD="$FAKE_SUDO pacman --noconfirm -Syyy && $FAKE_SUDO pacman --noconfirm -Syu"
|
||||
elif [ "$(command -v apt)" ]; then CMD="$FAKE_SUDO apt -y update && $FAKE_SUDO apt -y upgrade"
|
||||
elif [ "$(command -v apk)" ]; then CMD="$FAKE_SUDO apk update && $FAKE_SUDO apk upgrade"
|
||||
elif [ "$(command -v dnf)" ]; then CMD="$FAKE_SUDO dnf -y update && $FAKE_SUDO apt -y upgrade"
|
||||
else CMD="echo '[ERROR] Incompatable System...'"; fi
|
||||
INDEX=1
|
||||
echo "[FAKE//OS] Update: $CMD"
|
||||
if ! eval "$CMD 2>> $FAKE_LOG"; then
|
||||
while ! eval "$CMD"; do
|
||||
INDEX=$(( INDEX + 1 ))
|
||||
echo "[ERROR] Retrying: Attempt $INDEX..."
|
||||
done
|
||||
fi
|
||||
echo "[UPDATE] ----> Completed in $INDEX attempt(s)" >> $FAKE_LOG
|
||||
}
|
||||
|
||||
|
||||
|
||||
# ┌───────────────────────────────────────┐
|
||||
# │ Install │
|
||||
# └───────────────────────────────────────┘
|
||||
_fake_install () {
|
||||
echo "[INSTALL] $@" >> $FAKE_LOG
|
||||
if [ "$(command -v paru)" ]; then CMD="$FAKE_BTL paru --noconfirm -S $@"
|
||||
elif [ "$(command -v pacman)" ]; then CMD="$FAKE_SUDO pacman --noconfirm -S $@"
|
||||
elif [ "$(command -v apt)" ]; then CMD="$FAKE_SUDO apt -y install $@"
|
||||
elif [ "$(command -v apk)" ]; then CMD="$FAKE_SUDO apk add $@"
|
||||
elif [ "$(command -v dnf)" ]; then CMD="$FAKE_SUDO dnf -y install $@"
|
||||
else CMD="echo '[ERROR] Incompatable System...'"; fi
|
||||
INDEX=1
|
||||
echo "[FAKE//OS] Install: $@"
|
||||
if ! eval "$CMD 2>> $FAKE_LOG"; then
|
||||
while ! eval "$CMD"; do
|
||||
INDEX=$(( INDEX + 1 ))
|
||||
echo "[ERROR] Retrying: Attempt $INDEX..."
|
||||
done
|
||||
fi
|
||||
echo "[INSTALL] ----> Completed in $INDEX attempt(s)" >> $FAKE_LOG
|
||||
}
|
||||
|
||||
|
||||
# ┌───────────────────────────────────────┐
|
||||
# │ Remove │
|
||||
# └───────────────────────────────────────┘
|
||||
_fake_remove () {
|
||||
echo "[REMOVE] $@" >> $FAKE_LOG
|
||||
if [ "$(command -v paru)" ]; then CMD="$FAKE_BTL paru --noconfirm -R $@"
|
||||
elif [ "$(command -v pacman)" ]; then CMD="$FAKE_SUDO pacman --noconfirm -R $@"
|
||||
elif [ "$(command -v apt)" ]; then CMD="$FAKE_SUDO apt -y remove $@"
|
||||
elif [ "$(command -v apk)" ]; then CMD="$FAKE_SUDO apk del $@"
|
||||
elif [ "$(command -v dnf)" ]; then CMD="$FAKE_SUDO dnf -y remove $@"
|
||||
else CMD="echo '[ERROR] Incompatable System...'"; fi
|
||||
INDEX=1
|
||||
echo "[FAKE//OS] Remove: $@"
|
||||
if ! eval "$CMD 2>> $FAKE_LOG"; then
|
||||
while ! eval "$CMD"; do
|
||||
INDEX=$(( INDEX + 1 ))
|
||||
echo "[ERROR] Retrying: Attempt $INDEX..."
|
||||
done
|
||||
fi
|
||||
echo "[REMOVE] ----> Completed in $INDEX attempt(s)" >> $FAKE_LOG
|
||||
}
|
||||
|
||||
|
||||
|
||||
# ┌───────────────────────────────────────┐
|
||||
# │ Search │
|
||||
# └───────────────────────────────────────┘
|
||||
_fake_search () {
|
||||
if [ "$(command -v paru)" ]; then CMD="paru -Ss $@"
|
||||
elif [ "$(command -v pacman)" ]; then CMD="pacman -Ss $@"
|
||||
elif [ "$(command -v apt)" ]; then CMD="apt search $@"
|
||||
elif [ "$(command -v apk)" ]; then CMD="apk search $@"
|
||||
elif [ "$(command -v dnf)" ]; then CMD="dnf search $@"
|
||||
else CMD="echo '[ERROR] Incompatable System...'"; fi
|
||||
echo "[FAKE//OS] Search: $@"
|
||||
if ! eval "$CMD 2>> $FAKE_LOG"; then
|
||||
echo "[FAKE//OS] Error: Search failed..."
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
# ┌───────────────────────────────────────┐
|
||||
# │ Service Daemon │
|
||||
# └───────────────────────────────────────┘
|
||||
_fake_start () { #--------[ Start Daemon ]
|
||||
echo "[START] $@"
|
||||
for SERVICE in $@; do
|
||||
if [ "$(command -v systemctl)" ]; then sudo systemctl start "$SERVICE" 2>> $FAKE_LOG; fi
|
||||
if [ "$(command -v rc-update)" ]; then sudo rc-service "$SERVICE" start 2>> $FAKE_LOG; fi
|
||||
done
|
||||
}
|
||||
_fake_stop () { #---------[ Stop Daemon ]
|
||||
echo "[STOP] $@"
|
||||
for SERVICE in $@; do
|
||||
if [ "$(command -v systemctl)" ]; then sudo systemctl start "$SERVICE" 2>> $FAKE_LOG; fi
|
||||
if [ "$(command -v rc-update)" ]; then sudo rc-service "$SERVICE" start 2>> $FAKE_LOG; fi
|
||||
done
|
||||
}
|
||||
_fake_restart () { #------[ Restart Daemon ]
|
||||
echo "[RESTART] $@"
|
||||
for SERVICE in $@; do
|
||||
if [ "$(command -v systemctl)" ]; then sudo systemctl restart "$SERVICE" 2>> $FAKE_LOG; fi
|
||||
if [ "$(command -v rc-update)" ]; then sudo rc-service "$SERVICE" restart 2>> $FAKE_LOG; fi
|
||||
done
|
||||
}
|
||||
_fake_enable () { #-------[ Enable Daemon at Startup ]
|
||||
echo "[ENABLE] $@"
|
||||
for SERVICE in $@; do
|
||||
if [ "$(command -v systemctl)" ]; then sudo systemctl enable "$SERVICE" 2>> $FAKE_LOG; fi
|
||||
if [ "$(command -v rc-update)" ]; then sudo rc-update add "$SERVICE" 2>> $FAKE_LOG; fi
|
||||
done
|
||||
}
|
||||
_fake_disable () { #------[ Disable Daeon at Startup ]
|
||||
echo "[DISABLE] $@"
|
||||
for SERVICE in $@; do
|
||||
if [ "$(command -v systemctl)" ]; then sudo systemctl disable "$SERVICE" 2>> $FAKE_LOG; fi
|
||||
if [ "$(command -v rc-update)" ]; then sudo rc-update rm "$SERVICE" 2>> $FAKE_LOG; fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
# ┌───────────────────────────────────────┐
|
||||
# │ Other Functions │
|
||||
# └───────────────────────────────────────┘
|
||||
_fake_flush () { #--------[ Flush System Cache ]
|
||||
sudo -u root $ENV_SHELL -c "sync; echo 3 > /proc/sys/vm/drop_caches"
|
||||
}
|
||||
|
||||
|
||||
|
||||
# ┌───────────────────────────────────────┐
|
||||
# │ Help Screen │
|
||||
# └───────────────────────────────────────┘
|
||||
_fake_help () {
|
||||
echo ""
|
||||
echo "FAKE//OS"
|
||||
echo "-----------------------------------"
|
||||
echo "usage: fake <command> <arguments>"
|
||||
echo ""
|
||||
echo "Package management commands:"
|
||||
echo " install Install new software packages"
|
||||
echo " update Update installed software packages"
|
||||
echo " remove Remove/Uninstall software packages"
|
||||
echo " search Search repository for software packages"
|
||||
echo ""
|
||||
echo "Init/System management commands"
|
||||
echo " start Start system daemons"
|
||||
echo " stop Stop system daemons"
|
||||
echo " restart Restart system daemons"
|
||||
echo " enable Add system daemons to default startup PID"
|
||||
echo " disable Remove system daemons from default startup PID"
|
||||
echo " flush Clear system caches"
|
||||
echo ""
|
||||
echo "FAKE//OS commands:"
|
||||
echo " upgrade Upgrade FAKE//OS to latest git version"
|
||||
echo " help Display this help screen"
|
||||
echo ""
|
||||
}
|
||||
|
||||
|
||||
# ┌───────────────────────────────────────┐
|
||||
# │ Main Entry Point │
|
||||
# └───────────────────────────────────────┘
|
||||
#--------[ Package Management ]--------#
|
||||
if [ "$1" == "update" ]; then _fake_update
|
||||
elif [ "$1" == "install" ]; then _fake_install "$VARS"
|
||||
elif [ "$1" == "remove" ]; then _fake_remove "$VARS"
|
||||
elif [ "$1" == "search" ]; then _fake_search "$VARS"
|
||||
#--------[ Service Daemon Management ]--------#
|
||||
elif [ "$1" == "start" ]; then _fake_start "$VARS"
|
||||
elif [ "$1" == "stop" ]; then _fake_stop "$VARS"
|
||||
elif [ "$1" == "restart" ]; then _fake_restart "$VARS"
|
||||
elif [ "$1" == "enable" ]; then _fake_enable "$VARS"
|
||||
elif [ "$1" == "disable" ]; then _fake_disable "$VARS"
|
||||
#--------[ Other Commands ]--------#
|
||||
elif [ "$1" == "flush" ]; then _fake_flush
|
||||
elif [ "$1" == "help" ]; then _fake_help
|
||||
#--------[ Error Catching ]--------#
|
||||
else echo "[ERROR] Command '$1' not recognised."; fi
|
42
src/fake_shell.sh
Normal file
42
src/fake_shell.sh
Normal file
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
|
||||
#--------[ FAKE//OS System Variables ]--------#
|
||||
export VISUAL=emacs
|
||||
export EDITOR=vim
|
||||
export FAKE_PATH=/opt/fakeos
|
||||
|
||||
|
||||
#--------[ Master Paths ]--------#
|
||||
if ! [ "$(echo $PATH | grep sbin)" ]; then
|
||||
export PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin"
|
||||
fi
|
||||
if ! [ "$(echo $PATH | grep games)" ]; then
|
||||
export PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin:/usr/games"
|
||||
fi
|
||||
|
||||
|
||||
#--------[ Terminal Colours ]--------#
|
||||
FCOL0="\e[0m"
|
||||
FCOL1="\e[37m\033[38;5;166m"
|
||||
FCOL2="\e[37m\033[38;5;204m"
|
||||
FCOL3="\e[37m\033[38;5;170m"
|
||||
FCOLGRAD="lolcat -p 4 -S 6 -F 0.1"
|
||||
FCOLBOLD="\e[1m"
|
||||
FCOLITAL="\e[2;3m"
|
||||
|
||||
|
||||
#--------[ CLI Prompt ]--------#
|
||||
if [ $(whoami) != "root" ]; then
|
||||
PS1="\[${FCOL0}\]\[[${FCOL3}\]\u\[${FCOL0}\]@\[${FCOL3}\]\h\[${FCOL0}\]] \W \$ "
|
||||
else
|
||||
PS1="\[${FCOL0}\]\[[${FCOL1}\]\u\[${FCOL0}\]@\[${FCOL1}\]\h\[${FCOL0}\]] \W \$ "
|
||||
fi
|
||||
|
||||
|
||||
#--------[ Login Display ]--------#
|
||||
echo ""
|
||||
cat $FAKE_PATH/assets/logo_full.txt
|
||||
echo ""
|
||||
echo -e "${FCOL1}user:${FCOL0} $(whoami) ${FCOL2}login:${FCOL0} $ENV_LOGIN ${FCOL3}system:${FCOL0} $ENV_ARCH $ENV_DISTRO"
|
||||
echo ""
|
Loading…
Reference in a new issue