close
Skip to content

CorelLinux/oci-simple-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 OCI Discord Bot

Fully Automated Always Free Instance Creator

OCI Always Free Discord Bot Bash Automation MIT License

Easily create Oracle Cloud Infrastructure Always Free instances from Discord!

🚀 Quick Start📖 Usage🔧 Advanced Setup🤝 Contributing

English | 한국어


🎬 Demo

📱 Discord Bot Commands Demo

# Example usage in Discord channel
/status                    # Check bot status and instance overview
/launch                    # Instantly create Always Free instance
/log count:5               # View last 5 execution logs
/config                    # Check current configuration

🧙‍♂️ Setup Wizard Execution Screen

╔══════════════════════════════════════════════════════════════════════════════╗
║                    🧙‍♂️ OCI Always Free Discord Bot                          ║
║                             Setup Wizard                                    ║
║         Oracle Cloud Infrastructure Always Free Instance Auto Creator      ║
╚══════════════════════════════════════════════════════════════════════════════╝

ℹ️ [12:34:56] 🎯 Always Free Optimized: E2.1.Micro (2x), A1.Flex (4 OCPU, 24GB)
ℹ️ [12:34:56] 🤖 Discord Integration: Slash commands, Real-time monitoring
ℹ️ [12:34:56] 🔧 Full Automation: Auto-detect config, Real-time validation

📊 Always Free Usage Monitoring

📊 Always Free Usage:
  • Shape: VM.Standard.A1.Flex
  • Specs: 2 OCPU, 12GB RAM
  • A1 Total Limit: 2/4 OCPU, 12/24GB RAM
  • Remaining Resources: 2 OCPU, 12GB RAM
  • Boot Volume: 100/200GB (Free)

💎 Oracle Cloud Always Free - What Is It?

Oracle Cloud Always Free provides powerful cloud infrastructure at no cost forever - perfect for developers, students, and small projects!

🎁 What Oracle Always Free Provides

🖥️ Compute Instances

  • 2x E2.1.Micro (AMD EPYC)
    • 1 OCPU, 1GB RAM each
    • Perfect for: Web servers, APIs, bots
  • 4 OCPU A1.Flex (ARM Ampere)
    • 4 OCPU, 24GB RAM total
    • Configurable: 1-4 instances

💾 Storage & Network

  • 200GB Block Storage
  • 10GB Object Storage
  • Load Balancer (10 Mbps)
  • VCN & Security Lists
  • Autonomous Database (20GB)

🎮 Popular Use Cases & Examples

🎯 A1.Flex (ARM) - High Performance Applications

🎮 Gaming Servers

# Minecraft Server (Recommended: 2 OCPU, 8GB)
Shape: VM.Standard.A1.Flex
Config: 2 OCPU, 8GB RAM
Players: ~10-20 concurrent
Performance: Excellent for modded servers

🌐 Development Environment

# Full Development Stack
Shape: VM.Standard.A1.Flex  
Config: 4 OCPU, 24GB RAM
Stack: Docker, Kubernetes, CI/CD
Perfect for: Team development, microservices

🤖 AI/ML Workloads

# Machine Learning Training
Config: 4 OCPU, 24GB RAM
Frameworks: TensorFlow, PyTorch
Use: Model training, data processing
⚡ E2.1.Micro (AMD) - Lightweight Services

🌐 Web Applications

  • Personal websites & blogs
  • REST APIs & microservices
  • Discord/Telegram bots
  • Monitoring services

📊 Database & Caching

  • Small databases (PostgreSQL, MySQL)
  • Redis cache servers
  • Message queues
  • Log aggregators

💰 Always Free vs Paid Comparison

Feature Always Free Paid Plans
Cost $0/month forever Pay-as-you-use
Performance Production-ready Scalable
Duration No time limit Flexible
Support Community Professional

💡 Pro Tip: Always Free is perfect for learning, development, and small production workloads. Scale to paid plans when you need more resources!


✨ Features

🎯 Always Free Optimized

  • E2.1.Micro (up to 2 instances)
  • A1.Flex (4 OCPU, 24GB RAM)
  • ✅ 200GB Boot Volume Free
  • ✅ Real-time limit checking

🤖 Discord Integration

  • ✅ Slash command support
  • ✅ Real-time status monitoring
  • ✅ Log and error notifications
  • ✅ PM2 service management

🔧 Full Automation

  • ✅ Auto OCI CLI installation
  • ✅ Auto-detect existing config
  • ✅ Real-time API validation
  • ✅ One-click setup

🎨 User-Friendly

  • ✅ Colorful log output
  • ✅ Emoji-based UI
  • ✅ Step-by-step guidance
  • ✅ Auto error diagnosis

🚀 Core Features

🎯 Always Free Optimization
  • Shape Auto-filtering: Shows only E2.1.Micro, A1.Flex
  • Real-time limit check: Auto-calculate OCPU/RAM usage
  • Billing protection: Warns when exceeding Always Free limits
  • Usage dashboard: Real-time display of remaining resources
🤖 Discord Bot Commands
Command Function Example
/status Bot status and instance overview Uptime, success rate, recent activity
/launch Instant instance creation Auto-select Always Free Shape
/log View recent execution logs Success/failure history, error diagnosis
/config Check configuration info Current Shape, region, specs
/help All commands guide Usage and tips
🔧 Smart Setup Wizard
  • Auto environment detection: Auto-load existing OCI config files
  • Real-time API validation: Real-time query of available Shape/Image
  • Custom spec configuration: Auto-validate OCPU/RAM combinations
  • Intuitive UI: User-friendly interface

🛠️ Quick Start

1️⃣ Prerequisites

🔑 OCI Account

  • Oracle Cloud free account
  • Always Free eligibility confirmed
  • Credit card registration (free)

🤖 Discord Bot

🖥️ Server Environment

  • Linux (Ubuntu/CentOS)
  • Bash 4.0+
  • curl, jq installed

2️⃣ OCI API Key Setup

# 🔐 Generate API key pair
mkdir -p ~/.oci
openssl genrsa -out ~/.oci/oci_api_key.pem 2048
openssl rsa -pubout -in ~/.oci/oci_api_key.pem -out ~/.oci/oci_api_key_public.pem
chmod 600 ~/.oci/oci_api_key.pem

# 📋 Copy public key content (for OCI Console registration)
cat ~/.oci/oci_api_key_public.pem

🔗 OCI Console Registration Path
Identity & SecurityUsersYour AccountAPI KeysAdd API Key

3️⃣ OCI CLI Setup

# 🚀 Install OCI CLI (automatic)
bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"

# 📝 Interactive setup (recommended)
oci setup config

# 🔍 Verify configuration
oci iam region list --output table

4️⃣ Run Setup Wizard

# 📥 Download scripts
git clone https://github.com/CorelLinux/oci-simple-script.git
cd oci-simple-script

# 🧙‍♂️ Run setup wizard
bash oci-config-wizard.sh

🎉 Once all setup is complete, config.json will be auto-generated!

5️⃣ Run Discord Bot

# 🤖 Start bot
bash oci-script-and-bot.sh

# 📊 Check status
pm2 status
pm2 logs oci-discord-bot

🎮 Usage

Discord Commands

Command Icon Description Result
/status 📊 Check bot status Uptime, success rate, recent activity
/launch 🚀 Create instance Auto-select Always Free Shape
/log 📋 View logs Recent N execution history
/config ⚙️ Check configuration Current Shape, region, specs
/stop ⏹️ Stop auto creation Pause bot
/start ▶️ Restart auto creation Resume bot
/schedule Set creation interval 3-60 minutes (default: 5 min)
/stats 📊 Detailed statistics Success rate, period analysis
/instances 🖥️ List instances Running/stopped instance overview
/resources 💰 Resource usage Always Free limits and usage
/alert 🔔 Notification settings Configure alerts
/help Help All commands guide

Always Free Usage Monitoring

# 🔍 Check current instances
oci compute instance list --compartment-id $COMPARTMENT_ID --output table

# 📊 Check A1.Flex usage
oci limits resource-availability get --compartment-id $COMPARTMENT_ID \
    --service-name compute --limit-name vm-standard-a1-core-count

⚡ New Features in v2.0

Feature Description Benefit
🎯 Smart Interval Default 5-minute attempts Faster instance acquisition
⚙️ Flexible Timing 3-60 minute range via /schedule Customizable based on demand
🌐 Multi-language English/Korean support Better accessibility
🔧 Error Recovery Improved command error handling More stable operation
📊 Enhanced Stats Detailed success rate analysis Better monitoring

💡 Pro Tip: Use /schedule 3 during high-demand periods and /schedule 30 during low-demand periods to optimize success rates.


🎨 Advanced Setup

🎯 Always Free Optimization

💡 Shape Selection Guide
Shape OCPU RAM Instances Use Case Notes
E2.1.Micro 1 1GB 2 Lightweight web servers, bots AMD-based
A1.Flex 1-4 6-24GB 1-4 Development servers, learning ARM-based

💰 Cost Calculator:

  • E2.1.Micro: Free (up to 2)
  • A1.Flex: Total 4 OCPU, 24GB RAM free
  • Boot Volume: 200GB free
🔧 Custom SSH Keys
# 🔑 Use existing SSH keys
export CUSTOM_PRIVATE_KEY_PATH="/path/to/your/private_key"
export CUSTOM_PUBLIC_KEY_PATH="/path/to/your/public_key.pub"

# 🔐 Generate new SSH keys
ssh-keygen -t rsa -b 2048 -f ~/.ssh/oci_key -N ""
export CUSTOM_PRIVATE_KEY_PATH="$HOME/.ssh/oci_key"
export CUSTOM_PUBLIC_KEY_PATH="$HOME/.ssh/oci_key.pub"
🌐 Language Configuration

The bot supports both English and Korean interfaces. Configure in config.json:

{
  "LANGUAGE": "en",  // "en" for English, "ko" for Korean
  // ... other config options
}

Language Features:

  • 🎯 Discord command descriptions in chosen language
  • 📝 Bot response messages in chosen language
  • 🔧 Error messages and help text localized
  • 🚀 Seamless switching - just edit config and restart

Change Language:

# Edit config.json
nano config.json
# Change "LANGUAGE": "ko" to "LANGUAGE": "en"

# Restart bot
pm2 restart oci-discord-bot

🔧 Troubleshooting

🚨 Common Issues

❌ OCI CLI Installation Error

# 🔍 Check installation
oci --version

# 🔧 Check PATH configuration
echo $PATH | grep -o "$HOME/bin"

# 🔄 Reinstall
curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh | bash

❌ OCI CLI Not Accessible with sudo

When OCI CLI is installed via symlink in user path, it may not be accessible with sudo.

# 🔍 Check OCI CLI installation location
which oci
# Result: /home/user/bin/oci

# 🔧 Create symlink in system path
sudo ln -s $(which oci) /usr/local/bin/oci

# ✅ Verify sudo access
sudo oci --version

Automatic Solution:

# Script handles this automatically, but manual setup is also possible
sudo ln -s $HOME/bin/oci /usr/local/bin/oci
sudo ln -s $HOME/.local/bin/oci /usr/local/bin/oci
sudo ln -s $HOME/lib/oracle-cli/bin/oci /usr/local/bin/oci

❌ API Key Permission Error

# 🔐 Check and fix permissions
ls -la ~/.oci/
chmod 600 ~/.oci/oci_api_key.pem
chmod 644 ~/.oci/oci_api_key_public.pem

# 🔍 Validate key
oci iam region list --auth api_key

❌ Discord Bot Token Error

# 🔍 Check token
grep -o "discord_token" config.json

# 🔧 Reset token
bash oci-config-wizard.sh
# Re-run Discord configuration section only

❌ "Out of Capacity" Error

  • 🔄 Try different regions: ap-tokyo-1, ap-mumbai-1
  • ⏰ Change time zone: Recommended during early morning hours
  • 🎯 Change Shape: E2.1.Micro → A1.Flex
📊 Status Check Commands
# 🤖 Bot status
pm2 status
pm2 logs oci-discord-bot --lines 50

# 📊 Instance list
oci compute instance list --compartment-id $COMPARTMENT_ID --output table

# 💰 Always Free usage
oci limits resource-availability get \
    --compartment-id $COMPARTMENT_ID \
    --service-name compute \
    --limit-name vm-standard-a1-core-count
🔧 Configuration File Check
# 📄 OCI configuration
cat ~/.oci/config

# 📋 Bot configuration
cat config.json | jq .

# 📝 Log file
tail -f oci_bot.log

📚 References

🔗 Useful Links

Category Link Description
🏛️ Official Oracle Cloud Console OCI Management Console
📖 Documentation OCI CLI Guide Official Installation Guide
🤖 Bot Discord Developer Bot Creation and Management
💡 Tips Out of Capacity Solution Capacity shortage solution

🎓 Recommended Learning Resources


🤝 Contributing

🙋‍♂️ How to Participate

🐛 Bug Reports
Let us know about issues you find

Create Issue

💡 Feature Requests
Share your new ideas

Feature Request

🔧 Code Contributions
Write improvements yourself

Pull Request

📋 Contribution Guidelines

  1. 🍴 Fork this repository to your account
  2. 🌿 Branch Create a new feature branch
  3. 💻 Code Write improvements and test
  4. 📝 Commit Write clear commit messages
  5. 🚀 PR Create Pull Request

📄 License

MIT License - Feel free to use, modify, and distribute!

License: MIT


🌟 If this project helped you, please give it a Star!

Made with ❤️ for the Oracle Cloud Always Free Community

About

A Discord-based automation toolkit for Oracle Cloud Always Free.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages